Skip to content

test: create pool#785

Merged
rflechtner merged 18 commits intopallet_bonded_coinsfrom
rf-test-create-pool
Nov 6, 2024
Merged

test: create pool#785
rflechtner merged 18 commits intopallet_bonded_coinsfrom
rf-test-create-pool

Conversation

@rflechtner
Copy link
Contributor

@rflechtner rflechtner commented Nov 5, 2024

re/ KILTProtocol/ticket#3671

Adds unit tests for creating pools.
To be rebased and merged after #780

Tests currently failing (fix TBD in another PR):

  • Exhausting Asset Id value space should result in ArithmeticError::Overflow
  • You should not be able to create a pool where a bonded currency is also the pool's collateral

Checklist:

  • I have verified that the code works
    • No panics! (checked arithmetic ops, no indexing array[3] use get(3), ...)
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)
    • Either PR or Ticket to update the Docs
    • Link the PR/Ticket here

@rflechtner rflechtner changed the base branch from pallet_bonded_coins to ag_mock November 5, 2024 14:43
@rflechtner rflechtner requested review from Ad96el and ntn-x2 November 5, 2024 14:51
@rflechtner rflechtner changed the title test: create pool & reset manager/team test: create pool Nov 5, 2024
Base automatically changed from ag_mock to pallet_bonded_coins November 5, 2024 16:10

#[test]
fn multi_currency() {
let initial_balance = 100_000_000_000_000_000u128;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move the balance to mock. It is used multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.with_collaterals(vec![DEFAULT_COLLATERAL_CURRENCY_ID])
.build()
.execute_with(|| {
assert_eq!(NextAssetId::<Test>::get(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also check the deposit? We have checked it for a single currency. For multiple, it should differ.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't seem to be able to link to the right line, but this is being checked with

			assert_eq!(
 				Balances::free_balance(ACCOUNT_00),
 				initial_balance.sub(BondingPallet::calculate_pool_deposit(3))
 			);

@rflechtner rflechtner requested review from Ad96el and ntn-x2 November 6, 2024 13:11
@rflechtner rflechtner mentioned this pull request Nov 6, 2024
7 tasks
Copy link
Contributor

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough for me 👍

@rflechtner rflechtner merged commit b2c71b2 into pallet_bonded_coins Nov 6, 2024
@rflechtner rflechtner deleted the rf-test-create-pool branch November 6, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants