Skip to content

Commit

Permalink
upgrade xcm tests #CU-20465559 #INIT-84 (#3015)
Browse files Browse the repository at this point in the history
dzmitry-lahoda authored Feb 8, 2023
1 parent 58aaa48 commit a28d754
Showing 17 changed files with 426 additions and 183 deletions.
242 changes: 212 additions & 30 deletions code/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ members = [
"services/cmc-api",
"parachain/frame/*",
# TODO(hussein): let's upgrade them in v0.9.33
# "integration-tests/local-integration-tests",
"integration-tests/local-integration-tests",
"parachain/node",
"parachain/runtime/common",
"parachain/runtime/primitives",
25 changes: 17 additions & 8 deletions code/integration-tests/local-integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -37,7 +37,9 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }


# modules
pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
aura = { package = "pallet-aura", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
@@ -75,7 +77,6 @@ transaction-payment = { package = "pallet-transaction-payment", path = "../../pa

# Used for the node template's RPCs
system-rpc-runtime-api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "../../parachain/frame/transaction-payment", default-features = false }

# Used for runtime benchmarking
benchmarking = { package = "frame-benchmarking", git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.33" }
@@ -103,35 +104,41 @@ scale-info = { version = "2.1.1", default-features = false, features = [
] }
session-benchmarking = { package = "cumulus-pallet-session-benchmarking", git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.33" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
sp-keyring = { git = "https://github.com/paritytech/substrate", default-features = false }
sp-keyring = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.33" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }


kusama-runtime = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.33" }
parachains-common = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.33" }
paste = "1.0.6"
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
rococo-runtime = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.33" }
statemine-runtime = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.33" }
xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "ab5cd6c5fabe6ddda52ed6803ee1bf54c258fefe", default-features = false }
# cumulus depends on substrate https://github.com/paritytech/cumulus/blob/27721d794ee63aae42317a7eeda21595dd3200d9/Cargo.lock#L5282
# via https://github.com/paritytech/substrate?branch=polkadot-v0.9.33#2dff067e9f7f6f3cc4dbfdaaa97753eccc407689
# cumulus does https://github.com/paritytech/cumulus/blob/27721d794ee63aae42317a7eeda21595dd3200d9/parachains/runtimes/assets/statemine/src/weights/pallet_assets.rs#L64
# but there is no that methods in https://github.com/paritytech/substrate/blob/2dff067e9f7f6f3cc4dbfdaaa97753eccc407689/frame/assets/src/weights.rs#L49
# build of 9.33 borked because of that
# statemine-runtime = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.33" , optional = true }
xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "c62dbf8e247c03d9797dbf3f1886f74973f2b22a", default-features = false }

dali-runtime = { package = "dali-runtime", path = "../../parachain/runtime/dali", default-features = false, optional = true }
picasso-runtime = { package = "picasso-runtime", path = "../../parachain/runtime/picasso", default-features = false, optional = true }

[dev-dependencies]
base58 = "0.2"
env_logger = "0.9.0"
env_logger = "0.10.0"
hex = "0.4.3"
more-asserts = "0.3.1"

[features]
dali = ["std", "develop", "local-integration-tests", "rococo"]
default = ["std", "develop", "local-integration-tests", "dali"]
#statemine = ["statemine-runtime"]
kusama = []
local-integration-tests = [
"dali-runtime/local-integration-tests",
@@ -202,8 +209,9 @@ std = [
"polkadot-core-primitives/std",
"polkadot-primitives/std",
"polkadot-runtime-parachains/std",
"statemine-runtime/std",
#"statemine-runtime/std",
"parachains-common/std",
"pallet-assets/std",
]

runtime-benchmarks = [
@@ -236,7 +244,8 @@ runtime-benchmarks = [
"picasso-runtime/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"statemine-runtime/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
#"statemine-runtime/runtime-benchmarks",
]

develop = ["assets", "assets-registry", "governance-registry"]
16 changes: 16 additions & 0 deletions code/integration-tests/local-integration-tests/flake-module.nix
Original file line number Diff line number Diff line change
@@ -17,6 +17,22 @@
checkIntegrationTests { chainName = "dali"; };
check-picasso-integration-tests =
checkIntegrationTests { chainName = "picasso"; };

local-integration-tests =
pkgs.writeShellScriptBin "local-integration-tests" ''
cd code
RUST_BACKTRACE=full \
SKIP_WASM_BUILD=1 \
RUST_LOG=trace,bdd=trace,parity-db=warn,trie=warn,runtime=trace,substrate-relay=trace,bridge=trace,xcmp=trace,xcm=trace \
cargo +nightly test --package local-integration-tests --features=local-integration-tests,picasso, --no-default-features -- --nocapture --test-threads=1
'';
};

apps = {
local-integration-tests = self.inputs.flake-utils.lib.mkApp {
drv = self'.packages.local-integration-tests;
};
};

};
}
Original file line number Diff line number Diff line change
@@ -53,11 +53,13 @@ fn registered_assets_with_smaller_than_native_price() {
let asset_id = System::events()
.iter()
.find_map(|x| match x.event {
Event::AssetsRegistry(assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
}) => Some(asset_id),
RuntimeEvent::AssetsRegistry(
assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
},
) => Some(asset_id),
_ => None,
})
.unwrap();
@@ -83,11 +85,13 @@ fn registered_assets_with_larger_than_native_price() {
let asset_id = System::events()
.iter()
.find_map(|x| match x.event {
Event::AssetsRegistry(assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
}) => Some(asset_id),
RuntimeEvent::AssetsRegistry(
assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
},
) => Some(asset_id),
_ => None,
})
.unwrap();
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ fn transfer_native_from_relay_chain_to_statemine() {
KusamaRelay::execute_with(|| {
use relay_runtime::*;
assert_ok!(XcmPallet::teleport_assets(
Origin::signed(ALICE.into()),
RuntimeOrigin::signed(ALICE.into()),
Box::new(Parachain(topology::common_good_assets::ID).into().into()),
Box::new(Junction::AccountId32 { id: BOB, network: NetworkId::Any }.into().into()),
Box::new((Here, amount).into()),
@@ -59,7 +59,7 @@ fn transfer_native_from_statemine_to_this() {
KusamaRelay::execute_with(|| {
use relay_runtime::*;
assert_ok!(XcmPallet::teleport_assets(
Origin::signed(ALICE.into()),
RuntimeOrigin::signed(ALICE.into()),
Box::new(Parachain(topology::common_good_assets::ID).into().into()),
Box::new(Junction::AccountId32 { id: BOB, network: NetworkId::Any }.into().into()),
Box::new((Here, amount).into()),
@@ -70,7 +70,7 @@ fn transfer_native_from_statemine_to_this() {
let bob_balance = Statemine::execute_with(|| {
use statemine_runtime::*;
let bob_balance = Balances::balance(&AccountId::from(BOB));
let origin = Origin::signed(BOB.into());
let origin = RuntimeOrigin::signed(BOB.into());

assert_ok!(PolkadotXcm::reserve_transfer_assets(
origin,
@@ -117,7 +117,7 @@ fn transfer_usdt_from_statemine_to_this() {
.unwrap();
log::info!(target: "bdd", " and Bob has a lot USDT on Statemine");
Assets::mint(
Origin::signed(ALICE.into()),
RuntimeOrigin::signed(ALICE.into()),
statemine_asset_id as u32,
MultiAddress::Id(BOB.into()),
total_issuance,
@@ -128,7 +128,7 @@ fn transfer_usdt_from_statemine_to_this() {
Statemine::execute_with(|| {
log::info!(target: "bdd", "When Bob transfers some {:?} USDT from Statemine to Dali", usdt_transfer_amount);
use statemine_runtime::*;
let origin = Origin::signed(BOB.into());
let origin = RuntimeOrigin::signed(BOB.into());
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
origin,
Box::new(VersionedMultiLocation::V1(MultiLocation::new(
@@ -185,7 +185,7 @@ fn rockmine_shib_to_dali_transfer() {
.unwrap();
log::info!(target: "bdd", " and Bob has a lot SHIB on Statemine");
Assets::mint(
Origin::signed(ALICE.into()),
RuntimeOrigin::signed(ALICE.into()),
statemine_asset_id,
MultiAddress::Id(BOB.into()),
total_issuance,
@@ -215,11 +215,13 @@ fn rockmine_shib_to_dali_transfer() {
System::events()
.iter()
.find_map(|x| match x.event {
Event::AssetsRegistry(assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
}) => Some(asset_id),
RuntimeEvent::AssetsRegistry(
assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
},
) => Some(asset_id),
_ => None,
})
.unwrap()
@@ -229,7 +231,7 @@ fn rockmine_shib_to_dali_transfer() {
Statemine::execute_with(|| {
log::info!(target: "bdd", "When Bob transfers some {:?} SHIB from Statemine to Dali", transfer_amount);
use statemine_runtime::*;
let origin = Origin::signed(BOB.into());
let origin = RuntimeOrigin::signed(BOB.into());
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
origin,
Box::new(VersionedMultiLocation::V1(MultiLocation::new(
@@ -285,7 +287,7 @@ fn rockmine_stable_to_dali_transfer() {
.unwrap();
log::info!(target: "bdd", " and Bob has a lot STABLE on Statemine");
Assets::mint(
Origin::signed(ALICE.into()),
RuntimeOrigin::signed(ALICE.into()),
statemine_asset_id,
MultiAddress::Id(BOB.into()),
total_issuance,
@@ -317,11 +319,13 @@ fn rockmine_stable_to_dali_transfer() {
System::events()
.iter()
.find_map(|x| match x.event {
Event::AssetsRegistry(assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
}) => Some(asset_id),
RuntimeEvent::AssetsRegistry(
assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
},
) => Some(asset_id),
_ => None,
})
.unwrap()
@@ -330,7 +334,7 @@ fn rockmine_stable_to_dali_transfer() {
Statemine::execute_with(|| {
log::info!(target: "bdd", "When Bob transfers some {:?} STABLE from Statemine to Dali", transfer_amount);
use statemine_runtime::*;
let origin = Origin::signed(BOB.into());
let origin = RuntimeOrigin::signed(BOB.into());
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
origin,
Box::new(VersionedMultiLocation::V1(MultiLocation::new(
@@ -453,7 +457,7 @@ fn bob_has_statemine_asset_on_this_and_transfers_it_to_reserve(
assert!(relay_native_asset_amount != 0);
log::info!(target: "bdd", "Bob sending Statemine to reserve chain to his account");
let error = XTokens::transfer_multicurrencies(
Origin::signed(BOB.into()),
RuntimeOrigin::signed(BOB.into()),
vec![
(CurrencyId::RELAY_NATIVE, relay_native_asset_amount),
(foreign_asset_id_on_this, UNIT),
@@ -496,7 +500,7 @@ fn bob_has_statemine_asset_on_this_and_transfers_it_to_reserve(
.unwrap();

XTokens::transfer_multicurrencies(
Origin::signed(BOB.into()),
RuntimeOrigin::signed(BOB.into()),
vec![
(CurrencyId::RELAY_NATIVE, relay_native_asset_amount),
(foreign_asset_id_on_this, UNIT),
@@ -538,7 +542,7 @@ fn statemine_setup_assets(
) {
use statemine_runtime::*;
Statemine::execute_with(|| {
let origin = Origin::signed(ALICE.into());
let origin = RuntimeOrigin::signed(ALICE.into());
Balances::make_free_balance_be(&ALICE.into(), native_for_alice);
Balances::make_free_balance_be(&BOB.into(), native_for_bob);

@@ -581,7 +585,7 @@ fn statemine_side(this_parachain_account_init_amount: u128, statemine_asset_id:

Statemine::execute_with(|| {
log::info!(target: "bdd", "Alice transfers Statemine asset to Bob on This chain");
let origin = Origin::signed(ALICE.into());
let origin = RuntimeOrigin::signed(ALICE.into());

assert_ok!(PolkadotXcm::reserve_transfer_assets(
origin,
@@ -623,11 +627,13 @@ fn register_statemine_asset(remote_asset_id: CommonAssetId, ratio: Rational64) -
System::events()
.iter()
.find_map(|x| match x.event {
Event::AssetsRegistry(assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
}) => Some(asset_id),
RuntimeEvent::AssetsRegistry(
assets_registry::Event::<Runtime>::AssetRegistered {
asset_id,
location: _,
decimals: _,
},
) => Some(asset_id),
_ => None,
})
.unwrap()
@@ -700,7 +706,7 @@ fn cannot_reserve_transfer_from_two_consensuses_in_one_message() {
CurrencyId::RELAY_NATIVE,
&AccountId::from(bob()),
);
let origin = Origin::signed(bob().into());
let origin = RuntimeOrigin::signed(bob().into());
assert_ok!(RelayerXcm::limited_reserve_transfer_assets(
origin,
Box::new(VersionedMultiLocation::V1(MultiLocation::new(
Loading

0 comments on commit a28d754

Please sign in to comment.