Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Statemine XCM Simulator Tests #3548

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fde986a
init
4meta5 Aug 1, 2021
f806a95
reserve trasfer asset and query holding tests without message checking
4meta5 Aug 1, 2021
eb4224b
XcmSender short circuits on first successful impl for tuples apparently
4meta5 Aug 1, 2021
c65624d
add TestSendXcm XcmRouter to track sent messages
4meta5 Aug 1, 2021
e9da5ea
fix mistake removing local env stuff
4meta5 Aug 1, 2021
abc999f
fix
4meta5 Aug 1, 2021
6332854
add xcm simulator scenario for statemine-like chain
apopiak Aug 1, 2021
0ca47e0
update cargo.lock
apopiak Aug 1, 2021
8b5f212
add ReceivedDmp storage value to MockMsgQueue pallet to store all rec…
4meta5 Aug 2, 2021
6e4e6db
improve ump docs
apopiak Aug 2, 2021
f0e3ee3
make xcm-simulator XCM sending asynchronous
apopiak Aug 2, 2021
52bc4f0
remove xcm-test-utils
apopiak Aug 2, 2021
bfa9913
Update xcm/xcm-simulator/src/lib.rs
apopiak Aug 2, 2021
3f09caa
Merge branch 'apopiak/async-xcm-sim' of https://github.com/paritytech…
4meta5 Aug 2, 2021
86f7d51
use automatic dispatch of message queues to check query response func…
4meta5 Aug 2, 2021
d2b81f9
clean
4meta5 Aug 2, 2021
287cd76
Update xcm/xcm-simulator/src/lib.rs
4meta5 Aug 2, 2021
8305934
Update xcm/xcm-simulator/src/lib.rs
4meta5 Aug 2, 2021
0444d45
Update xcm/xcm-simulator/src/lib.rs
4meta5 Aug 2, 2021
8e60c11
spellcheck nit
4meta5 Aug 2, 2021
35250b5
Merge branch 'amar-more-simulator-tests' of https://github.com/4meta5…
4meta5 Aug 2, 2021
daed1fd
clean
4meta5 Aug 2, 2021
68c725f
fix fmt in macro
4meta5 Aug 2, 2021
25adec4
Merge branch 'amar-more-simulator-tests' of github.com:4meta5/polkado…
apopiak Aug 2, 2021
2577245
add moonriver like runtime and reserve based transfer scenario
apopiak Aug 2, 2021
fa4bac1
address review comments
4meta5 Aug 3, 2021
7f19aef
fix typo
apopiak Aug 3, 2021
7b34f7d
move imports
apopiak Aug 3, 2021
719f151
formatting
apopiak Aug 3, 2021
3567cd9
Merge branch 'amar-more-simulator-tests' of github.com:4meta5/polkado…
apopiak Aug 3, 2021
2903c07
remove statemine checking account
apopiak Aug 3, 2021
48c404f
Merge branch 'apopiak/statemine-simulator-tests' of github.com:parity…
apopiak Aug 3, 2021
e659ec7
make xcm simulator async
4meta5 Aug 10, 2021
e622922
fmt
4meta5 Aug 10, 2021
03c4c7c
nightly fmt
4meta5 Aug 10, 2021
75b3bfa
Merge branch 'amar-extend-xcm-simulator' of github.com:4meta5/polkado…
apopiak Aug 12, 2021
a2f524b
add StatemineLike as reserve to KaruraLike
apopiak Aug 16, 2021
139b072
Merge branch 'master' of github.com:paritytech/polkadot into apopiak/…
apopiak Aug 20, 2021
b1e232c
Merge branch 'master' of github.com:paritytech/polkadot into apopiak/…
apopiak Sep 10, 2021
eedf757
update xcm simulator statemine example to XCM v2
apopiak Sep 10, 2021
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
37 changes: 37 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ members = [
"xcm/xcm-executor/integration-tests",
"xcm/xcm-simulator",
"xcm/xcm-simulator/example",
"xcm/xcm-simulator/statemine-like-example",
"xcm/pallet-xcm",
"xcm/procedural",
"node/client",
Expand Down
7 changes: 4 additions & 3 deletions runtime/parachains/src/ump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ pub use pallet::*;
/// It is possible that by the time the message is sank the origin parachain was offboarded. It is
/// up to the implementer to check that if it cares.
pub trait UmpSink {
/// Process an incoming upward message and return the amount of weight it consumed, or `None` if
/// it did not begin processing a message since it would otherwise exceed `max_weight`.
/// Process an incoming upward message and return the amount of weight it consumed, or
/// `Err(message_id, required_weight)` if it did not begin processing a message since it would
/// otherwise exceed `max_weight`.
///
/// See the trait docs for more details.
fn process_upward_message(
Expand All @@ -55,7 +56,7 @@ pub trait UmpSink {
}

/// An implementation of a sink that just swallows the message without consuming any weight. Returns
/// `Some(0)` indicating that no messages existed for it to process.
/// `Ok(0)` indicating that no messages existed for it to process.
impl UmpSink for () {
fn process_upward_message(
_: ParaId,
Expand Down
28 changes: 26 additions & 2 deletions xcm/xcm-simulator/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities {

pub fn relay_ext() -> sp_io::TestExternalities {
use relay_chain::{Runtime, System};
let para_account_a: relay_chain::AccountId = ParaId::from(1).into_account();

let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

Expand Down Expand Up @@ -195,8 +196,12 @@ mod tests {
});
}

/// Scenario:
/// A user Alice sends funds from the relaychain to a parachain.
///
/// Asserts that the correct XCM is sent and the balances are set as expected.
#[test]
fn reserve_transfer() {
fn reserve_transfer_assets() {
MockNet::reset();

let withdraw_amount = 123;
Expand All @@ -216,7 +221,26 @@ mod tests {
});

ParaA::execute_with(|| {
// free execution, full amount received
// Check message received
let expected_message = (
X1(Parent),
ReserveAssetDeposit {
assets: vec![ConcreteFungible { id: X1(Parent), amount: withdraw_amount }],
effects: vec![
buy_execution(max_weight_for_execution),
Order::DepositAsset {
assets: All.into(),
max_assets: 1,
beneficiary: X1(Junction::AccountId32 {
network: NetworkId::Any,
id: ALICE.into(),
}).into(),
},
],
},
);
assert_eq!(parachain::MsgQueue::received_dmp(), vec![expected_message]);
// Check message execution with full amount received
assert_eq!(
pallet_balances::Pallet::<parachain::Runtime>::free_balance(&ALICE),
INITIAL_BALANCE + withdraw_amount
Expand Down
7 changes: 6 additions & 1 deletion xcm/xcm-simulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Test kit to simulate cross-chain message passing and XCM execution

pub use codec::Encode;
pub use codec::{Decode, Encode};
pub use paste;

pub use frame_support::{traits::Get, weights::Weight};
Expand Down Expand Up @@ -219,7 +219,9 @@ macro_rules! decl_test_network {
$crate::RELAY_MESSAGE_BUS.with(|b| b.replace(VecDeque::new()));
// Reset parachain message bus
$crate::PARA_MESSAGE_BUS.with(|b| b.replace(VecDeque::new()));
// Reset relay chain state
<$relay_chain>::reset_ext();
// Reset parachain state
$( <$parachain>::reset_ext(); )*
}
}
Expand Down Expand Up @@ -319,6 +321,9 @@ macro_rules! decl_test_network {

/// XCM router for relay chain.
pub struct RelayChainXcmRouter;



impl $crate::SendXcm for RelayChainXcmRouter {
fn send_xcm(destination: $crate::MultiLocation, message: $crate::Xcm<()>) -> $crate::SendResult {
use $crate::DmpMessageHandlerT;
Expand Down
29 changes: 29 additions & 0 deletions xcm/xcm-simulator/statemine-like-example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "xcm-statemine-like-example"
version = "0.9.8"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Examples of XCM interactions with a Statemine-like chain."
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0" }
paste = "1.0.5"

frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }

xcm = { path = "../../" }
xcm-simulator = { path = "../" }
xcm-executor = { path = "../../xcm-executor" }
xcm-builder = { path = "../../xcm-builder" }
pallet-xcm = { path = "../../pallet-xcm" }
polkadot-core-primitives = { path = "../../../core-primitives"}
polkadot-runtime-parachains = { path = "../../../runtime/parachains" }
polkadot-parachain = { path = "../../../parachain" }

Loading