Skip to content

Commit

Permalink
test for mint_into. Refactor mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Ad96el committed Sep 20, 2024
1 parent a7f2cec commit cd28d42
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pallets/pallet-bonded-coins/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ pub mod runtime {
}
}

pub(crate) fn events() -> Vec<crate::Event<Test>> {
System::events()
.into_iter()
.map(|r| r.event)
.filter_map(|e| {
if let RuntimeEvent::BondingPallet(e) = e {
Some(e)
} else {
None
}
})
.collect::<Vec<_>>()
}

frame_support::construct_runtime!(
pub enum Test
{
Expand All @@ -103,7 +117,7 @@ pub mod runtime {
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = ();
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight;
type Version = ();
Expand Down Expand Up @@ -134,7 +148,7 @@ pub mod runtime {
type MaxFreezes = ();
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
Expand All @@ -149,7 +163,7 @@ pub mod runtime {
}

impl pallet_assets::Config for Test {
type RuntimeEvent = ();
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = AssetId;
type AssetIdParameter = AssetId;
Expand Down Expand Up @@ -185,7 +199,7 @@ pub mod runtime {
type MaxStringLength = StringLimit;
type PoolCreateOrigin = EnsureSigned<AccountId>;
type PoolId = AccountId;
type RuntimeEvent = ();
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = RuntimeHoldReason;
type AssetId = AssetId;
type BaseDeposit = ExistentialDeposit;
Expand Down Expand Up @@ -271,6 +285,8 @@ pub mod runtime {
let mut ext = sp_io::TestExternalities::new(storage);

ext.execute_with(|| {
System::set_block_number(System::block_number() + 1);

self.pools.iter().for_each(|(pool_id, pool)| {
crate::Pools::<Test>::insert(pool_id.clone(), pool.clone());

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ fn test_create_pool() {

// check if pool_account is created.
assert!(Assets::contains(&DEFAULT_COLLATERAL_CURRENCY_ID, &pool_id));

// check events

assert_eq!(events(), vec![crate::Event::<Test>::PoolCreated(pool_id)])
});
}
2 changes: 2 additions & 0 deletions pallets/pallet-bonded-coins/src/tests/transactions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
mod create_pool;
mod mint_into;

mod burn_into;

0 comments on commit cd28d42

Please sign in to comment.