Skip to content

Commit 57d3668

Browse files
Add create_pool_with_wnd_on
1 parent 4eca734 commit 57d3668

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

  • cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests

cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,67 @@ mod swap;
2424
mod teleport;
2525
mod treasury;
2626
mod xcm_fee_estimation;
27+
28+
#[macro_export]
29+
macro_rules! create_pool_with_wnd_on {
30+
( $chain:ident, $asset_id:expr, $is_foreign:expr, $asset_owner:expr ) => {
31+
emulated_integration_tests_common::impls::paste::paste! {
32+
<$chain>::execute_with(|| {
33+
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
34+
let owner = $asset_owner;
35+
let signed_owner = <$chain as Chain>::RuntimeOrigin::signed(owner.clone());
36+
let wnd_location: Location = Parent.into();
37+
if $is_foreign {
38+
assert_ok!(<$chain as [<$chain Pallet>]>::ForeignAssets::mint(
39+
signed_owner.clone(),
40+
$asset_id.clone().into(),
41+
owner.clone().into(),
42+
10_000_000_000_000, // For it to have more than enough.
43+
));
44+
} else {
45+
let asset_id = match $asset_id.interior.last() {
46+
Some(GeneralIndex(id)) => *id as u32,
47+
_ => unreachable!(),
48+
};
49+
assert_ok!(<$chain as [<$chain Pallet>]>::Assets::mint(
50+
signed_owner.clone(),
51+
asset_id.into(),
52+
owner.clone().into(),
53+
10_000_000_000_000, // For it to have more than enough.
54+
));
55+
}
56+
57+
assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::create_pool(
58+
signed_owner.clone(),
59+
Box::new(wnd_location.clone()),
60+
Box::new($asset_id.clone()),
61+
));
62+
63+
assert_expected_events!(
64+
$chain,
65+
vec![
66+
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {},
67+
]
68+
);
69+
70+
assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::add_liquidity(
71+
signed_owner,
72+
Box::new(wnd_location),
73+
Box::new($asset_id),
74+
1_000_000_000_000,
75+
2_000_000_000_000, // $asset_id is worth half of wnd
76+
0,
77+
0,
78+
owner.into()
79+
));
80+
81+
assert_expected_events!(
82+
$chain,
83+
vec![
84+
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded { .. }) => {},
85+
]
86+
);
87+
});
88+
}
89+
};
90+
}

0 commit comments

Comments
 (0)