diff --git a/integration-tests/emulated/chains/parachains/assets/asset-hub-kusama/src/genesis.rs b/integration-tests/emulated/chains/parachains/assets/asset-hub-kusama/src/genesis.rs index b1677e8762..fbd1e7303f 100644 --- a/integration-tests/emulated/chains/parachains/assets/asset-hub-kusama/src/genesis.rs +++ b/integration-tests/emulated/chains/parachains/assets/asset-hub-kusama/src/genesis.rs @@ -18,7 +18,8 @@ use sp_core::storage::Storage; // Cumulus use emulated_integration_tests_common::{ - accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, + accounts, build_genesis_storage, collators, PenpalSiblingSovereignAccount, + PenpalTeleportableAssetLocation, SAFE_XCM_VERSION, }; use parachains_common::Balance; @@ -60,6 +61,18 @@ pub fn genesis() -> Storage { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() }, + foreign_assets: asset_hub_kusama_runtime::ForeignAssetsConfig { + assets: vec![ + // Penpal's teleportable asset representation + ( + PenpalTeleportableAssetLocation::get(), + PenpalSiblingSovereignAccount::get(), + true, + ED, + ), + ], + ..Default::default() + }, ..Default::default() }; diff --git a/integration-tests/emulated/chains/parachains/assets/asset-hub-polkadot/src/genesis.rs b/integration-tests/emulated/chains/parachains/assets/asset-hub-polkadot/src/genesis.rs index 671eb79b67..70a5981198 100644 --- a/integration-tests/emulated/chains/parachains/assets/asset-hub-polkadot/src/genesis.rs +++ b/integration-tests/emulated/chains/parachains/assets/asset-hub-polkadot/src/genesis.rs @@ -18,7 +18,8 @@ use sp_core::storage::Storage; // Cumulus use emulated_integration_tests_common::{ - accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, SAFE_XCM_VERSION, + accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, + PenpalSiblingSovereignAccount, PenpalTeleportableAssetLocation, SAFE_XCM_VERSION, }; use parachains_common::{AccountId, AssetHubPolkadotAuraId, Balance}; use sp_core::sr25519; @@ -74,6 +75,18 @@ pub fn genesis() -> Storage { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() }, + foreign_assets: asset_hub_polkadot_runtime::ForeignAssetsConfig { + assets: vec![ + // Penpal's teleportable asset representation + ( + PenpalTeleportableAssetLocation::get(), + PenpalSiblingSovereignAccount::get(), + true, + ED, + ), + ], + ..Default::default() + }, ..Default::default() }; diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/swap.rs b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/swap.rs index 6565c31b53..881ece1e7e 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/swap.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/swap.rs @@ -123,42 +123,26 @@ fn swap_locally_on_chain_using_foreign_assets() { v3::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get()) .expect("conversion works"), ); - - let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubKusama::para_id()); let asset_location_on_penpal = v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works"); - let asset_id_on_penpal = match asset_location_on_penpal.last() { - Some(v3::Junction::GeneralIndex(id)) => *id as u32, - _ => unreachable!(), - }; - let asset_owner_on_penpal = PenpalASender::get(); let foreign_asset_at_asset_hub_kusama = v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())]) .appended_with(asset_location_on_penpal) .unwrap(); - // 1. Create asset on penpal and, 2. Create foreign asset on asset_hub_kusama - /* - // FAIL-CI @bkontur - super::penpal_create_foreign_asset_on_asset_hub( - asset_id_on_penpal, - foreign_asset_at_asset_hub_kusama, - ah_as_seen_by_penpal, - true, - asset_owner_on_penpal, - ASSET_MIN_BALANCE * 1_000_000, - );*/ - let penpal_as_seen_by_ah = AssetHubKusama::sibling_location_of(PenpalA::para_id()); let sov_penpal_on_ahk = AssetHubKusama::sovereign_account_id_of(penpal_as_seen_by_ah); AssetHubKusama::fund_accounts(vec![ - (AssetHubKusamaSender::get(), 5_000_000 * ASSET_HUB_KUSAMA_ED), /* An account to swap - * ksm - * for something else. */ + // An account to swap ksmfor something else. + (AssetHubKusamaSender::get(), 5_000_000 * ASSET_HUB_KUSAMA_ED), + // Penpal's sovereign account in AH should have some balance + (sov_penpal_on_ahk.clone().into(), 100_000_000 * ASSET_HUB_KUSAMA_ED), ]); AssetHubKusama::execute_with(|| { - // 3: Mint foreign asset on asset_hub_kusama: + // 0: No need to create foreign asset as it exists in genesis. + // + // 1:: Mint foreign asset on asset_hub_kusama: // // (While it might be nice to use batch, // currently that's disabled due to safe call filters.) @@ -169,7 +153,7 @@ fn swap_locally_on_chain_using_foreign_assets() { ::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()), foreign_asset_at_asset_hub_kusama, sov_penpal_on_ahk.clone().into(), - 3_000_000_000_000, + ASSET_HUB_KUSAMA_ED * 3_000_000_000_000, )); assert_expected_events!( @@ -221,8 +205,8 @@ fn swap_locally_on_chain_using_foreign_assets() { ::AssetConversion::swap_exact_tokens_for_tokens( ::RuntimeOrigin::signed(AssetHubKusamaSender::get()), path, - 100000, - 1000, + 100000 * ASSET_HUB_KUSAMA_ED, + 1000 * ASSET_HUB_KUSAMA_ED, AssetHubKusamaSender::get(), true ) @@ -232,8 +216,8 @@ fn swap_locally_on_chain_using_foreign_assets() { AssetHubKusama, vec![ RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. },) => { - amount_in: *amount_in == 100000, - amount_out: *amount_out == 199399, + amount_in: *amount_in == 333333300000, + amount_out: *amount_out == 498874118173, }, ] ); @@ -243,7 +227,7 @@ fn swap_locally_on_chain_using_foreign_assets() { ::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()), asset_native.clone(), Box::new(foreign_asset_at_asset_hub_kusama), - 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. + 1414213562273 / 2, // remove only half 0, 0, sov_penpal_on_ahk.clone(), diff --git a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/swap.rs b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/swap.rs index a040f79f5f..cb46e55b2d 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/swap.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/swap.rs @@ -132,42 +132,26 @@ fn swap_locally_on_chain_using_foreign_assets() { v3::Location::try_from(asset_hub_polkadot_runtime::xcm_config::DotLocation::get()) .expect("conversion works"), ); - - let ah_as_seen_by_penpal = PenpalB::sibling_location_of(AssetHubPolkadot::para_id()); let asset_location_on_penpal = v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works"); - let asset_id_on_penpal = match asset_location_on_penpal.last() { - Some(v3::Junction::GeneralIndex(id)) => *id as u32, - _ => unreachable!(), - }; - let asset_owner_on_penpal = PenpalBSender::get(); let foreign_asset_at_asset_hub_polkadot = - v3::Location::new(1, [v3::Junction::Parachain(PenpalB::para_id().into())]) + v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())]) .appended_with(asset_location_on_penpal) .unwrap(); - // 1. Create asset on penpal and, 2. Create foreign asset on asset_hub_polkadot - /* - // FAIL-CI @bkontur - super::penpal_create_foreign_asset_on_asset_hub( - asset_id_on_penpal, - foreign_asset_at_asset_hub_polkadot, - ah_as_seen_by_penpal, - true, - asset_owner_on_penpal, - ASSET_MIN_BALANCE * 1_000_000, - );*/ - - let penpal_as_seen_by_ah = AssetHubPolkadot::sibling_location_of(PenpalB::para_id()); - let sov_penpal_on_ahk = AssetHubPolkadot::sovereign_account_id_of(penpal_as_seen_by_ah); + let penpal_as_seen_by_ah = AssetHubPolkadot::sibling_location_of(PenpalA::para_id()); + let sov_penpal_on_ahp = AssetHubPolkadot::sovereign_account_id_of(penpal_as_seen_by_ah); AssetHubPolkadot::fund_accounts(vec![ - (AssetHubPolkadotSender::get(), 5_000_000 * POLKADOT_ED), /* An account to swap - * dot - * for something else. */ + // An account to swap dot for something else. + (AssetHubPolkadotSender::get(), 5_000_000 * ASSET_HUB_POLKADOT_ED), + // Penpal's sovereign account in AH should have some balance + (sov_penpal_on_ahp.clone().into(), 100_000_000 * ASSET_HUB_POLKADOT_ED), ]); AssetHubPolkadot::execute_with(|| { - // 3: Mint foreign asset on asset_hub_polkadot: + // 0: No need to create foreign asset as it exists in genesis. + // + // 1:: Mint foreign asset on asset_hub_polkadot: // // (While it might be nice to use batch, // currently that's disabled due to safe call filters.) @@ -175,10 +159,10 @@ fn swap_locally_on_chain_using_foreign_assets() { type RuntimeEvent = ::RuntimeEvent; // 3. Mint foreign asset (in reality this should be a teleport or some such) assert_ok!(::ForeignAssets::mint( - ::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()), + ::RuntimeOrigin::signed(sov_penpal_on_ahp.clone()), foreign_asset_at_asset_hub_polkadot, - sov_penpal_on_ahk.clone().into(), - 3_000_000_000_000, + sov_penpal_on_ahp.clone().into(), + ASSET_HUB_POLKADOT_ED * 3_000_000_000_000, )); assert_expected_events!( @@ -204,14 +188,14 @@ fn swap_locally_on_chain_using_foreign_assets() { // 5. Add liquidity: assert_ok!(::AssetConversion::add_liquidity( - ::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()), + ::RuntimeOrigin::signed(sov_penpal_on_ahp.clone()), asset_native.clone(), Box::new(foreign_asset_at_asset_hub_polkadot), 1_000_000_000_000, 2_000_000_000_000, 0, 0, - sov_penpal_on_ahk.clone() + sov_penpal_on_ahp.clone() )); assert_expected_events!( @@ -230,8 +214,8 @@ fn swap_locally_on_chain_using_foreign_assets() { ::AssetConversion::swap_exact_tokens_for_tokens( ::RuntimeOrigin::signed(AssetHubPolkadotSender::get()), path, - 100000, - 1000, + 100000 * ASSET_HUB_POLKADOT_ED, + 1000 * ASSET_HUB_POLKADOT_ED, AssetHubPolkadotSender::get(), true ) @@ -241,8 +225,8 @@ fn swap_locally_on_chain_using_foreign_assets() { AssetHubPolkadot, vec![ RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapExecuted { amount_in, amount_out, .. },) => { - amount_in: *amount_in == 100000, - amount_out: *amount_out == 199399, + amount_in: *amount_in == 10000000000000, + amount_out: *amount_out == 1817684594348, }, ] ); @@ -250,13 +234,13 @@ fn swap_locally_on_chain_using_foreign_assets() { // 7. Remove liquidity assert_ok!( ::AssetConversion::remove_liquidity( - ::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()), + ::RuntimeOrigin::signed(sov_penpal_on_ahp.clone()), asset_native.clone(), Box::new(foreign_asset_at_asset_hub_polkadot), - 1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved. + 1414213562273 / 2, // remove only half 0, 0, - sov_penpal_on_ahk.clone(), + sov_penpal_on_ahp.clone(), ) ); });