Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <AssetHubKusama as Chain>::RuntimeCall::System(frame_system::Call::<
<AssetHubKusama as Chain>::Runtime,
>::remark {
remark: vec![],
})
.encode()
.into();
let root = <Kusama as Chain>::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!(<Kusama as KusamaPallet>::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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function penpal_register_foreign_asset_on_asset_hub is nearly identical to the one added in integration-tests/emulated/tests/assets/asset-hub-polkadot/src/tests/send.rs. Consider moving this logic to a shared helper to avoid code duplication.

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();
Expand Down Expand Up @@ -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 {
Expand All @@ -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 = <AssetHubKusama as Chain>::RuntimeEvent;

Expand Down Expand Up @@ -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,
Comment on lines +222 to +225

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The owner and min_balance arguments for create_foreign_asset_call appear to be swapped. ASSET_MIN_BALANCE is being passed as the owner, and para_sovereign_account is passed as the minimum balance. This will lead to a runtime error or incorrect behavior. They should be swapped to match the expected signature (id, owner, min_balance).

);

let penpal_root = <PenpalA as Chain>::RuntimeOrigin::root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = <AssetHubKusama as Chain>::RuntimeCall::System(frame_system::Call::<
<AssetHubKusama as Chain>::Runtime,
>::remark {
remark: vec![],
})
.encode()
.into();

let penpal_root = <PenpalA as Chain>::RuntimeOrigin::root();
let fee_amount = 4_000_000_000_000u128;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <AssetHubPolkadot as Chain>::RuntimeCall::System(frame_system::Call::<
<AssetHubPolkadot as Chain>::Runtime,
>::remark {
remark: vec![],
})
.encode()
.into();
let root = <Polkadot as Chain>::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!(<Polkadot as PolkadotPallet>::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();
Expand Down Expand Up @@ -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;

Expand All @@ -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 = <AssetHubPolkadot as Chain>::RuntimeEvent;

Expand Down Expand Up @@ -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,
Comment on lines +229 to +232

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The owner and min_balance arguments for create_foreign_asset_call appear to be swapped. ASSET_MIN_BALANCE is being passed as the owner, and para_sovereign_account is passed as the minimum balance. This will lead to a runtime error or incorrect behavior. They should be swapped to match the expected signature (id, owner, min_balance).

);

let penpal_root = <PenpalB as Chain>::RuntimeOrigin::root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 = <AssetHubPolkadot as Chain>::RuntimeCall::System(frame_system::Call::<
<AssetHubPolkadot as Chain>::Runtime,
>::remark {
remark: vec![],
})
.encode()
.into();

let penpal_root = <PenpalB as Chain>::RuntimeOrigin::root();
let fee_amount = 4_000_000_000_000u128;
Expand Down
Loading