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

XCM-emulator test for multi-assets #2480

Draft
wants to merge 29 commits into
base: nacho/improve-xcm-emulator
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4733416
Bump syn from 2.0.13 to 2.0.14 (#2446)
dependabot[bot] Apr 12, 2023
5a0ebad
Bump serde from 1.0.159 to 1.0.160 (#2445)
dependabot[bot] Apr 12, 2023
030db02
Invoke cargo build commands with `--locked` (#2444)
Apr 12, 2023
df9ed24
Bump actions/checkout from 3.1.0 to 3.5.1 (#2448)
dependabot[bot] Apr 12, 2023
574f425
Bump serde_json from 1.0.95 to 1.0.96 (#2453)
dependabot[bot] Apr 13, 2023
b42855d
Bump actions/checkout from 3.5.1 to 3.5.2 (#2452)
dependabot[bot] Apr 14, 2023
a26ebb2
Bump syn from 2.0.14 to 2.0.15 (#2454)
dependabot[bot] Apr 14, 2023
863e94d
Bump assert_cmd from 2.0.10 to 2.0.11 (#2457)
dependabot[bot] Apr 15, 2023
72349fc
Changed `query_account_balances` return type (#2455)
bkontur Apr 17, 2023
926799c
Companion for substrate#13883 (#2460)
andresilva Apr 18, 2023
3de5354
Optimize level monitor reconstruction (#2461)
davxy Apr 19, 2023
4449044
Bump clap from 4.1.14 to 4.2.3 (#2465)
dependabot[bot] Apr 19, 2023
ea44f8c
Bump Swatinem/rust-cache from 2.2.0 to 2.2.1 (#2456)
dependabot[bot] Apr 19, 2023
d403b49
Companion for substrate#13771 (#2410)
muharem Apr 19, 2023
eced0cb
Parachain node should not recover blocks while syncing (#2462)
skunert Apr 19, 2023
8615ac8
[Polkadot Companion] for 7101 (#2470)
mrcnski Apr 21, 2023
71350eb
[Feature] XCM-Emulator
ruseinov Apr 12, 2023
c6612c6
".git/.scripts/commands/fmt/fmt.sh"
Apr 12, 2023
a277a05
rename
ruseinov Apr 12, 2023
0e74076
readme
ruseinov Apr 12, 2023
c664ba5
more rename
ruseinov Apr 12, 2023
d7b8960
rename directory
ruseinov Apr 12, 2023
4dfe34c
implement AssetTransactor
ruseinov Apr 12, 2023
464e19a
Update xcm/xcm-emulator/README.md
ruseinov Apr 13, 2023
6f13ceb
copy in the xcm-emulator
tonyalaribe Apr 19, 2023
10c7546
copy in the xcm-emulator
tonyalaribe Apr 19, 2023
16d5ce2
save and include logic for statemine xcm-emulator tests
tonyalaribe Apr 21, 2023
92e3db6
working integration tests
tonyalaribe Apr 21, 2023
866ff08
remove unnneeded
tonyalaribe Apr 24, 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
Prev Previous commit
Next Next commit
".git/.scripts/commands/fmt/fmt.sh"
  • Loading branch information
command-bot authored and tonyalaribe committed Apr 21, 2023
commit c6612c6f725f9b2852fd6844147aec88a5e93728
91 changes: 47 additions & 44 deletions xcm/xcm-emulator/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,29 @@ pub const INITIAL_BALANCE: u128 = 1_000_000_000_000;
pub fn yayoi_ext(para_id: u32) -> sp_io::TestExternalities {
use yayoi::{Runtime, System};

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

let parachain_info_config = parachain_info::GenesisConfig {
parachain_id: para_id.into(),
};
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();

<parachain_info::GenesisConfig as GenesisBuild<Runtime, _>>::assimilate_storage(&parachain_info_config, &mut t)
.unwrap();
let parachain_info_config = parachain_info::GenesisConfig { parachain_id: para_id.into() };

pallet_balances::GenesisConfig::<Runtime> {
balances: vec![(ALICE, INITIAL_BALANCE)],
}
.assimilate_storage(&mut t)
<parachain_info::GenesisConfig as GenesisBuild<Runtime, _>>::assimilate_storage(
&parachain_info_config,
&mut t,
)
.unwrap();

pallet_balances::GenesisConfig::<Runtime> { balances: vec![(ALICE, INITIAL_BALANCE)] }
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}

fn default_parachains_host_configuration(
) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::v4::BlockNumber> {
) -> polkadot_runtime_parachains::configuration::HostConfiguration<
polkadot_primitives::v4::BlockNumber,
> {
use polkadot_primitives::v4::{MAX_CODE_SIZE, MAX_POV_SIZE};

polkadot_runtime_parachains::configuration::HostConfiguration {
Expand Down Expand Up @@ -140,15 +139,11 @@ fn default_parachains_host_configuration(
pub fn kusama_ext() -> sp_io::TestExternalities {
use kusama_runtime::{Runtime, System};

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

pallet_balances::GenesisConfig::<Runtime> {
balances: vec![(ALICE, INITIAL_BALANCE)],
}
.assimilate_storage(&mut t)
.unwrap();
pallet_balances::GenesisConfig::<Runtime> { balances: vec![(ALICE, INITIAL_BALANCE)] }
.assimilate_storage(&mut t)
.unwrap();

polkadot_runtime_parachains::configuration::GenesisConfig::<Runtime> {
config: default_parachains_host_configuration(),
Expand Down Expand Up @@ -176,9 +171,10 @@ mod tests {
fn dmp() {
Network::reset();

let remark = yayoi::RuntimeCall::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: "Hello from Kusama!".as_bytes().to_vec(),
});
let remark =
yayoi::RuntimeCall::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: "Hello from Kusama!".as_bytes().to_vec(),
});
KusamaNet::execute_with(|| {
assert_ok!(kusama_runtime::XcmPallet::force_default_xcm_version(
kusama_runtime::RuntimeOrigin::root(),
Expand Down Expand Up @@ -221,10 +217,11 @@ mod tests {
);
});

let remark =
kusama_runtime::RuntimeCall::System(frame_system::Call::<kusama_runtime::Runtime>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
let remark = kusama_runtime::RuntimeCall::System(frame_system::Call::<
kusama_runtime::Runtime,
>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
YayoiPumpkin::execute_with(|| {
assert_ok!(yayoi::PolkadotXcm::force_default_xcm_version(
yayoi::RuntimeOrigin::root(),
Expand All @@ -234,13 +231,13 @@ mod tests {
Here,
Parent,
Xcm(vec![
UnpaidExecution {
weight_limit: Unlimited,
check_origin: None,
},
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::SovereignAccount,
require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024),
require_weight_at_most: Weight::from_parts(
INITIAL_BALANCE as u64,
1024 * 1024
),
call: remark.encode().into(),
}
]),
Expand Down Expand Up @@ -269,9 +266,10 @@ mod tests {
fn xcmp() {
Network::reset();

let remark = yayoi::RuntimeCall::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
let remark =
yayoi::RuntimeCall::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: "Hello from Pumpkin!".as_bytes().to_vec(),
});
YayoiPumpkin::execute_with(|| {
assert_ok!(yayoi::PolkadotXcm::send_xcm(
Here,
Expand Down Expand Up @@ -333,9 +331,10 @@ mod tests {
use yayoi::{RuntimeEvent, System};
System::events().iter().for_each(|r| println!(">>> {:?}", r.event));

assert!(System::events()
.iter()
.any(|r| matches!(r.event, RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent(_, _, _)))));
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent(_, _, _))
)));
});

YayoiOctopus::execute_with(|| {
Expand Down Expand Up @@ -391,17 +390,21 @@ mod tests {
}

fn kusama_send_rmrk(msg: &str, count: u32) {
let remark = yayoi::RuntimeCall::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: msg.as_bytes().to_vec(),
});
let remark =
yayoi::RuntimeCall::System(frame_system::Call::<yayoi::Runtime>::remark_with_event {
remark: msg.as_bytes().to_vec(),
});
KusamaNet::execute_with(|| {
for _ in 0..count {
assert_ok!(kusama_runtime::XcmPallet::send_xcm(
Here,
Parachain(1),
Xcm(vec![Transact {
origin_kind: OriginKind::SovereignAccount,
require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024),
require_weight_at_most: Weight::from_parts(
INITIAL_BALANCE as u64,
1024 * 1024
),
call: remark.encode().into(),
}]),
));
Expand Down