@@ -24,3 +24,67 @@ mod swap;
2424mod teleport;
2525mod treasury;
2626mod 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