diff --git a/Cargo.lock b/Cargo.lock index b5a5d11f3d..effbdfc0c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -839,6 +839,7 @@ dependencies = [ "cumulus-pallet-parachain-system", "emulated-integration-tests-common", "frame-support", + "frame-system", "hex-literal", "integration-tests-helpers", "kusama-runtime-constants", @@ -1013,6 +1014,7 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", "frame-support", + "frame-system", "hex-literal", "integration-tests-helpers", "pallet-asset-conversion", diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/Cargo.toml b/integration-tests/emulated/tests/assets/asset-hub-kusama/Cargo.toml index ae68ae432c..0ef36782a6 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/Cargo.toml +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/Cargo.toml @@ -15,6 +15,7 @@ hex-literal = { workspace = true } # Substrate sp-runtime = { workspace = true, default-features = true } frame-support = { workspace = true, default-features = true } +frame-system = { workspace = true, default-features = true } pallet-assets = { workspace = true, default-features = true } pallet-balances = { workspace = true, default-features = true } pallet-asset-conversion = { workspace = true, default-features = true } @@ -48,6 +49,7 @@ runtime-benchmarks = [ "asset-hub-kusama-runtime/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", "integration-tests-helpers/runtime-benchmarks", "kusama-runtime-constants/runtime-benchmarks", "kusama-runtime/runtime-benchmarks", diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/lib.rs b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/lib.rs index c3e1311646..814dd3abb0 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/lib.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/lib.rs @@ -47,7 +47,7 @@ pub use emulated_integration_tests_common::{ pub use integration_tests_helpers::{ test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, }; -pub use kusama_runtime::xcm_config::UniversalLocation as KusamaUniversalLocation; +pub use kusama_runtime::{xcm_config::UniversalLocation as KusamaUniversalLocation, Dmp}; pub use kusama_system_emulated_network::{ asset_hub_kusama_emulated_chain::{ genesis::{AssetHubKusamaAssetOwner, ED as ASSET_HUB_KUSAMA_ED}, diff --git a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/send.rs b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/send.rs index 2a0fa97b41..6dbd013bbc 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/send.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/send.rs @@ -18,27 +18,36 @@ use crate::*; /// Relay Chain should be able to execute `Transact` instructions in System Parachain /// when `OriginKind::Superuser`. #[test] -#[ignore] fn send_transact_as_superuser_from_relay_to_asset_hub_works() { - AssetHubKusama::force_create_asset_from_relay_as_root( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubKusamaSender::get(), - None, - ) + Kusama::execute_with(|| { + // send xcm transact to AssetHubKusama from root account on Relay + let call = ::RuntimeCall::System(frame_system::Call::< + ::Runtime, + >::remark { + remark: vec![], + }) + .encode() + .into(); + let root = ::RuntimeOrigin::root(); + let asset_hub_location = Kusama::child_location_of(AssetHubKusama::para_id()).into(); + let xcm = xcm_transact_unpaid_execution(call, OriginKind::Superuser); + Dmp::make_parachain_reachable(AssetHubKusama::para_id()); + assert_ok!(::XcmPallet::send( + root, + bx!(asset_hub_location), + bx!(xcm), + )); + Kusama::assert_xcm_pallet_sent(); + }); + AssetHubKusama::execute_with(|| { + AssetHubKusama::assert_xcmp_queue_success(None); + }); } -/// We tests two things here: -/// - Parachain should be able to send XCM paying its fee at Asset Hub using KSM -/// - Parachain should be able to create a new Foreign Asset at Asset Hub -#[test] -fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { +pub fn penpal_register_foreign_asset_on_asset_hub(asset_location_on_penpal: Location) { let para_sovereign_account = AssetHubKusama::sovereign_account_id_of( AssetHubKusama::sibling_location_of(PenpalA::para_id()), ); - let asset_location_on_penpal = - Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())]); let foreign_asset_at_asset_hub = Location::new(1, [Parachain(PenpalA::para_id().into())]) .appended_with(asset_location_on_penpal) .unwrap(); @@ -104,11 +113,20 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { }); } +/// We tests two things here: +/// - Parachain should be able to send XCM paying its fee at Asset Hub using KSM +/// - Parachain should be able to create a new Foreign Asset at Asset Hub +#[test] +fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { + let asset_location_on_penpal = + Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())]); + penpal_register_foreign_asset_on_asset_hub(asset_location_on_penpal); +} + /// We tests two things here: /// - Parachain should be able to send XCM paying its fee at Asset Hub using a pool /// - Parachain should be able to create a new Asset at Asset Hub #[test] -#[ignore] fn send_xcm_from_para_to_asset_hub_paying_fee_from_pool() { let asset_native: Location = asset_hub_kusama_runtime::xcm_config::KsmLocation::get(); let asset_one = Location { @@ -118,7 +136,6 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_from_pool() { let penpal = AssetHubKusama::sovereign_account_id_of(AssetHubKusama::sibling_location_of( PenpalA::para_id(), )); - AssetHubKusama::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -189,14 +206,23 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_from_pool() { )); }); + let penpal_para_id = PenpalA::para_id(); PenpalA::execute_with(|| { - // send xcm transact from `penpal` account which has only `ASSET_ID` tokens on - // `AssetHubKusama` - let call = AssetHubKusama::force_create_asset_call( - ASSET_ID + 1000, - penpal.clone(), - true, + let foreign_asset_at_asset_hub = Location::new( + 1, + [ + Parachain(penpal_para_id.into()), + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(ASSET_ID.into()), + ], + ); + let para_sovereign_account = AssetHubKusama::sovereign_account_id_of( + AssetHubKusama::sibling_location_of(penpal_para_id), + ); + let call = AssetHubKusama::create_foreign_asset_call( + foreign_asset_at_asset_hub.clone(), ASSET_MIN_BALANCE, + para_sovereign_account, ); let penpal_root = ::RuntimeOrigin::root(); 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 e54e1ec9d7..e5a815ead7 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 @@ -262,7 +262,6 @@ fn cannot_create_pool_from_pool_assets() { } #[test] -#[ignore] fn pay_xcm_fee_with_some_asset_swapped_for_native() { let asset_native: Location = asset_hub_kusama_runtime::xcm_config::KsmLocation::get(); let asset_one = Location { @@ -344,14 +343,15 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() { }); PenpalA::execute_with(|| { - // send xcm transact from `penpal` account which has only `ASSET_ID` tokens on + // send xcm transact from `penpal` account while paying with `ASSET_ID` tokens on // `AssetHubKusama` - let call = AssetHubKusama::force_create_asset_call( - ASSET_ID + 1000, - penpal.clone(), - true, - ASSET_MIN_BALANCE, - ); + let call = ::RuntimeCall::System(frame_system::Call::< + ::Runtime, + >::remark { + remark: vec![], + }) + .encode() + .into(); let penpal_root = ::RuntimeOrigin::root(); let fee_amount = 4_000_000_000_000u128; diff --git a/integration-tests/emulated/tests/assets/asset-hub-polkadot/Cargo.toml b/integration-tests/emulated/tests/assets/asset-hub-polkadot/Cargo.toml index 8521d59648..6bb54b39da 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-polkadot/Cargo.toml +++ b/integration-tests/emulated/tests/assets/asset-hub-polkadot/Cargo.toml @@ -15,6 +15,7 @@ hex-literal = { workspace = true } # Substrate sp-runtime = { workspace = true, default-features = true } frame-support = { workspace = true, default-features = true } +frame-system = { workspace = true, default-features = true } pallet-balances = { workspace = true, default-features = true } pallet-assets = { workspace = true, default-features = true } pallet-asset-conversion = { workspace = true, default-features = true } @@ -49,6 +50,7 @@ runtime-benchmarks = [ "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", "integration-tests-helpers/runtime-benchmarks", "pallet-asset-conversion/runtime-benchmarks", "pallet-assets/runtime-benchmarks", diff --git a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/lib.rs b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/lib.rs index b8b5577c2a..9518a78140 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/lib.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/lib.rs @@ -50,7 +50,7 @@ pub use integration_tests_helpers::{ test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter, }; pub use parachains_common::{AccountId, Balance}; -pub use polkadot_runtime::xcm_config::UniversalLocation as PolkadotUniversalLocation; +pub use polkadot_runtime::{xcm_config::UniversalLocation as PolkadotUniversalLocation, Dmp}; pub use polkadot_system_emulated_network::{ asset_hub_polkadot_emulated_chain::{ genesis::{AssetHubPolkadotAssetOwner, ED as ASSET_HUB_POLKADOT_ED}, diff --git a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/send.rs b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/send.rs index 18fabd91b5..b6576bceab 100644 --- a/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/send.rs +++ b/integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/send.rs @@ -18,27 +18,36 @@ use crate::*; /// Relay Chain should be able to execute `Transact` instructions in System Parachain /// when `OriginKind::Superuser`. #[test] -#[ignore] fn send_transact_as_superuser_from_relay_to_asset_hub_works() { - AssetHubPolkadot::force_create_asset_from_relay_as_root( - ASSET_ID, - ASSET_MIN_BALANCE, - true, - AssetHubPolkadotSender::get(), - None, - ) + Polkadot::execute_with(|| { + // send xcm transact to AssetHubPolkadot from root account on Relay + let call = ::RuntimeCall::System(frame_system::Call::< + ::Runtime, + >::remark { + remark: vec![], + }) + .encode() + .into(); + let root = ::RuntimeOrigin::root(); + let asset_hub_location = Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + let xcm = xcm_transact_unpaid_execution(call, OriginKind::Superuser); + Dmp::make_parachain_reachable(AssetHubPolkadot::para_id()); + assert_ok!(::XcmPallet::send( + root, + bx!(asset_hub_location), + bx!(xcm), + )); + Polkadot::assert_xcm_pallet_sent(); + }); + AssetHubPolkadot::execute_with(|| { + AssetHubPolkadot::assert_xcmp_queue_success(None); + }); } -/// We tests two things here: -/// - Parachain should be able to send XCM paying its fee at Asset Hub using DOT -/// - Parachain should be able to create a new Foreign Asset at Asset Hub -#[test] -fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { +pub fn penpal_register_foreign_asset_on_asset_hub(asset_location_on_penpal: Location) { let para_sovereign_account = AssetHubPolkadot::sovereign_account_id_of( AssetHubPolkadot::sibling_location_of(PenpalA::para_id()), ); - let asset_location_on_penpal = - Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())]); let foreign_asset_at_asset_hub = Location::new(1, [Parachain(PenpalA::para_id().into())]) .appended_with(asset_location_on_penpal) .unwrap(); @@ -104,11 +113,20 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { }); } +/// We tests two things here: +/// - Parachain should be able to send XCM paying its fee at Asset Hub using DOT +/// - Parachain should be able to create a new Foreign Asset at Asset Hub +#[test] +fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() { + let asset_location_on_penpal = + Location::new(0, [PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())]); + penpal_register_foreign_asset_on_asset_hub(asset_location_on_penpal); +} + /// We tests two things here: /// - Parachain should be able to send XCM paying its fee at Asset Hub using a pool /// - Parachain should be able to create a new Asset at Asset Hub #[test] -#[ignore] fn send_xcm_from_para_to_asset_hub_paying_fee_from_pool() { use frame_support::traits::fungible::Mutate; @@ -120,7 +138,6 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_from_pool() { let penpal = AssetHubPolkadot::sovereign_account_id_of(AssetHubPolkadot::sibling_location_of( PenpalB::para_id(), )); - AssetHubPolkadot::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -196,14 +213,23 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_from_pool() { )); }); + let penpal_para_id = PenpalB::para_id(); PenpalB::execute_with(|| { - // send xcm transact from `penpal` account which as only `ASSET_ID` tokens on - // `AssetHubPolkadot` - let call = AssetHubPolkadot::force_create_asset_call( - ASSET_ID + 1000, - penpal.clone(), - true, + let foreign_asset_at_asset_hub = Location::new( + 1, + [ + Parachain(penpal_para_id.into()), + PalletInstance(ASSETS_PALLET_ID), + GeneralIndex(ASSET_ID.into()), + ], + ); + let para_sovereign_account = AssetHubPolkadot::sovereign_account_id_of( + AssetHubPolkadot::sibling_location_of(penpal_para_id), + ); + let call = AssetHubPolkadot::create_foreign_asset_call( + foreign_asset_at_asset_hub.clone(), ASSET_MIN_BALANCE, + para_sovereign_account, ); let penpal_root = ::RuntimeOrigin::root(); 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 20e1cd9f20..1e6b26477f 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 @@ -273,7 +273,6 @@ fn cannot_create_pool_from_pool_assets() { } #[test] -#[ignore] fn pay_xcm_fee_with_some_asset_swapped_for_native() { use frame_support::traits::fungible::Mutate; @@ -362,14 +361,15 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() { }); PenpalB::execute_with(|| { - // send xcm transact from `penpal` account which as only `ASSET_ID` tokens on + // send xcm transact from `penpal` account while paying with `ASSET_ID` tokens on // `AssetHubPolkadot` - let call = AssetHubPolkadot::force_create_asset_call( - ASSET_ID + 1000, - penpal.clone(), - true, - ASSET_MIN_BALANCE, - ); + let call = ::RuntimeCall::System(frame_system::Call::< + ::Runtime, + >::remark { + remark: vec![], + }) + .encode() + .into(); let penpal_root = ::RuntimeOrigin::root(); let fee_amount = 4_000_000_000_000u128;