Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6f28e70
folder restructutre
NachoPal Apr 24, 2023
721a12f
common created
NachoPal Apr 24, 2023
11eb54f
make macros repetitions
NachoPal Apr 24, 2023
fb5f5c7
messenger traits for relay and para
NachoPal Apr 25, 2023
f216cf7
default Messenger impls
NachoPal Apr 25, 2023
1e3a5d4
messenger traits refactor
NachoPal Apr 25, 2023
0fdf215
declared two networks
NachoPal Apr 25, 2023
8cedf41
init network approach works
NachoPal Apr 25, 2023
729f918
queues use HashMap but relay block number
NachoPal Apr 26, 2023
b45cc42
init and reset refactor
NachoPal Apr 26, 2023
19f775d
messengers trait name changed
NachoPal Apr 26, 2023
769ecf4
relay block number suboptimal
NachoPal Apr 26, 2023
38cf3d9
fix reset hashmap keys
NachoPal Apr 26, 2023
eac6a88
genesis added
NachoPal Apr 26, 2023
7c4dd47
test ext added for parachains
NachoPal Apr 27, 2023
0490ab6
genesis added relay chains
NachoPal Apr 27, 2023
edb8684
genesis to storage
NachoPal Apr 27, 2023
3a99e03
new_ext replaced by on_init
NachoPal May 4, 2023
b7f54e6
new relay block number approach
NachoPal May 5, 2023
066a0c9
ext_wrapper added
NachoPal May 5, 2023
fb62068
added types to Parachain trait
NachoPal May 5, 2023
b11de13
relay chain with types
NachoPal May 6, 2023
fd295d0
restructure
NachoPal May 6, 2023
75ceebe
para_ids working
NachoPal May 7, 2023
694722d
replace para_id getter
NachoPal May 7, 2023
1e99b42
replace para_id getter 2
NachoPal May 7, 2023
fe5f5c2
tests restructure + common variables
NachoPal May 8, 2023
b65e027
added sovereign and balances helpers
NachoPal May 8, 2023
b963e38
more helpers + tess pass
NachoPal May 11, 2023
45f4c4a
expected events macro added
NachoPal May 11, 2023
89f0fc9
added events trait method
NachoPal May 11, 2023
5faf54a
expect_events macro improve
NachoPal May 12, 2023
06962cb
expect_events macro done
NachoPal May 12, 2023
53eef96
network traits added
NachoPal May 13, 2023
36eb693
reserve_transfer test added
NachoPal May 13, 2023
342e526
para & relay macro inputs redefined
NachoPal May 13, 2023
839b32b
added collectives & BH paras
NachoPal May 14, 2023
0f6d89a
test restructure
NachoPal May 14, 2023
84dea0a
statemine removed
NachoPal May 14, 2023
406886c
nitpick
NachoPal May 14, 2023
0f3afd2
rename test folder + events logs
NachoPal May 17, 2023
dc7ff20
clean
NachoPal May 17, 2023
c948348
merged branch
NachoPal May 17, 2023
b21d95d
weight threshold helper
NachoPal May 17, 2023
478549e
update readme
NachoPal May 17, 2023
c4bbcad
remove cumulus-test-service dependancy
NachoPal May 17, 2023
28b418b
fmt
NachoPal May 17, 2023
8c3b5ea
comment docs
NachoPal May 18, 2023
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
136 changes: 83 additions & 53 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ members = [
"parachains/runtimes/collectives/collectives-polkadot",
"parachains/runtimes/contracts/contracts-rococo",
"parachains/runtimes/testing/penpal",
"parachains/integration-tests/emulated/common",
"parachains/integration-tests/emulated/assets/statemint",
"test/client",
"test/relay-sproof-builder",
"test/relay-validation-worker-provider",
"test/runtime",
"test/service",
"xcm/xcm-emulator",
"xcm/xcm-emulator/example",
"xcm/xcm-emulator/example/test-runtime",
]

[profile.release]
Expand All @@ -68,4 +68,3 @@ opt-level = 3
inherits = "release"
lto = true
codegen-units = 1

36 changes: 36 additions & 0 deletions parachains/integration-tests/emulated/assets/statemint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "statemint-it"
version = "1.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
description = "Statemint parachain runtime integration tests with xcm-emulator"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }

# Substrate
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot
polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }

# Cumulus
parachains-common = { path = "../../../../common" }
penpal-runtime = { path = "../../../../runtimes/testing/penpal" }
statemint-runtime = { path = "../../../../runtimes/assets/statemint" }

# Local
xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" }
integration-tests-common = { default-features = false, path = "../../common" }
33 changes: 33 additions & 0 deletions parachains/integration-tests/emulated/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pub use codec::Encode;
pub use frame_support::{
assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect,
};
pub use integration_tests_common::{
constants::{
accounts::{ALICE, BOB},
polkadot::ED as POLKADOT_ED,
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
},
AccountId, BHKusama, BHKusamaPallet, BHKusamaReceiver, BHKusamaSender, BHPolkadot,
BHPolkadotPallet, BHPolkadotReceiver, BHPolkadotSender, Collectives, CollectivesPallet,
CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver,
KusamaSender, PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot,
PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet,
PolkadotReceiver, PolkadotSender, Statemine, StateminePallet, StatemineReceiver,
StatemineSender, Statemint, StatemintPallet, StatemintReceiver, StatemintSender,
};
pub use polkadot_core_primitives::InboundDownwardMessage;
pub use xcm::{
prelude::*,
v3::{
Error,
NetworkId::{Kusama as KusamaId, Polkadot as PolkadotId},
},
};
pub use xcm_emulator::{
assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold,
Parachain as Para, RelayChain as Relay, TestExt,
};

#[cfg(test)]
mod tests;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod reserve_transfer;
mod teleport;
mod transact;
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use crate::*;

#[test]
fn reserve_transfer_native_asset_from_relay_to_assets() {
// Init tests variables
let amount = POLKADOT_ED * 1000;
let relay_sender_balance_before = Polkadot::account_data_of(PolkadotSender::get()).free;
let para_receiver_balance_before = Statemint::account_data_of(StatemintReceiver::get()).free;

let origin = <Polkadot as Relay>::RuntimeOrigin::signed(PolkadotSender::get());
let assets_para_destination: VersionedMultiLocation =
Polkadot::child_location_of(Statemint::para_id()).into();
let beneficiary: VersionedMultiLocation =
AccountId32 { network: None, id: StatemintReceiver::get().into() }.into();
let native_assets: VersionedMultiAssets = (Here, amount).into();
let fee_asset_item = 0;
let weight_limit = WeightLimit::Unlimited;

// Send XCM message from Relay Chain
Polkadot::execute_with(|| {
assert_ok!(<Polkadot as PolkadotPallet>::XcmPallet::limited_reserve_transfer_assets(
origin,
bx!(assets_para_destination),
bx!(beneficiary),
bx!(native_assets),
fee_asset_item,
weight_limit,
));

type RuntimeEvent = <Polkadot as Relay>::RuntimeEvent;

assert_expected_events!(
Polkadot,
vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted(Outcome::Complete(weight))) => {
weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(2_000_000_000, 0), *weight),
},
]
);
});

// Receive XCM message in Assets Parachain
Statemint::execute_with(|| {
type RuntimeEvent = <Statemint as Para>::RuntimeEvent;

assert_expected_events!(
Statemint,
vec![
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
outcome: Outcome::Incomplete(_, Error::UntrustedReserveLocation),
..
}) => {},
]
);
});

// Check if balances are updated accordingly in Relay Chain and Assets Parachain
let relay_sender_balance_after = Polkadot::account_data_of(PolkadotSender::get()).free;
let para_sender_balance_after = Statemint::account_data_of(StatemintReceiver::get()).free;

assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after);
assert_eq!(para_sender_balance_after, para_receiver_balance_before);
}
Loading