Files
pezkuwi-runtime-templates/evm-template/runtime/tests/xcm_mock/mod.rs
T
Amar Singh 2bfcbf94d5 Upgrade evm-template to polkadot-stable2503 (#417)
* init 2503 upgrade for evm template need to upgrade frontier forks

* start upgrading frontier

* wip upgrading tanssi deps and synchronizing deps therein

* update tanssi wip

* fix dep tree for evm template and move onto resolving errors

* resolve 17 of 29 compilation errors 12 remaining most related to updating weight files

* resolve weight related compilation errors and evm abstraction and proc macro require updates

* impl DecodeWithMemTracking for custom origins 5 errors left requiring changes to astractions

* update evm abstraction runtime compiles

* node in progress frontier txpool requires more changes

* update txpool for node and node release compiles

* remove unused code commented out

* fix tanssi registrar benchmarking compilation

* fix pallet registrar benchmarks and unit tests

* update tanssi runtime apis to have benchmark features

* clean and fix some errors tests are recently requiring benchmark hidden impls oddly

* combine ci steps for running test and checking benchmark compilation to see if output changes

* update xcm core buyer 2412 dep to 2503 release ty @KitHat

* rm conditional compilation for runtime benchmarks inside a few declarative macro definitions

* apply clippy fix

* move runtime benchmarks declarations for referenda conviction voting and assets common into the runtime not sure why only those require explicit feature declaration

* break build but apply suggestions from @KitHat

* fix build

* fix toml sort

* fix tanssi build
2025-08-01 10:28:26 -04:00

128 lines
4.0 KiB
Rust

pub mod parachain;
pub mod relay_chain;
use sp_runtime::BuildStorage;
use sp_tracing;
use xcm::prelude::*;
use xcm_executor::traits::ConvertLocation;
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt};
pub const PARA_ALICE: [u8; 20] = [1u8; 20];
pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([1u8; 32]);
pub const INITIAL_BALANCE: u128 = 1_000_000_000;
decl_test_parachain! {
pub struct ParaA {
Runtime = parachain::Runtime,
XcmpMessageHandler = parachain::MsgQueue,
DmpMessageHandler = parachain::MsgQueue,
new_ext = para_ext(1),
}
}
decl_test_parachain! {
pub struct ParaB {
Runtime = parachain::Runtime,
XcmpMessageHandler = parachain::MsgQueue,
DmpMessageHandler = parachain::MsgQueue,
new_ext = para_ext(2),
}
}
decl_test_relay_chain! {
pub struct Relay {
Runtime = relay_chain::Runtime,
RuntimeCall = relay_chain::RuntimeCall,
RuntimeEvent = relay_chain::RuntimeEvent,
XcmConfig = relay_chain::XcmConfig,
MessageQueue = relay_chain::MessageQueue,
System = relay_chain::System,
new_ext = relay_ext(),
}
}
decl_test_network! {
pub struct MockNet {
relay_chain = Relay,
parachains = vec![
(1, ParaA),
(2, ParaB),
],
}
}
pub fn parent_account_id() -> parachain::AccountId {
let location = (Parent,);
parachain::location_converter::LocationConverter::convert_location(&location.into()).unwrap()
}
pub fn child_account_id(para: u32) -> relay_chain::AccountId {
let location = (Parachain(para),);
relay_chain::location_converter::LocationConverter::convert_location(&location.into()).unwrap()
}
pub fn child_account_account_id(para: u32, who: sp_runtime::AccountId32) -> relay_chain::AccountId {
let location = (Parachain(para), AccountId32 { network: None, id: who.into() });
relay_chain::location_converter::LocationConverter::convert_location(&location.into()).unwrap()
}
pub fn sibling_account_account_id(para: u32, who: sp_runtime::AccountId32) -> parachain::AccountId {
let location = (Parent, Parachain(para), AccountId32 { network: None, id: who.into() });
parachain::location_converter::LocationConverter::convert_location(&location.into()).unwrap()
}
pub fn parent_account_account_id(who: sp_runtime::AccountId32) -> parachain::AccountId {
let location = (Parent, AccountId32 { network: None, id: who.into() });
parachain::location_converter::LocationConverter::convert_location(&location.into()).unwrap()
}
pub fn para_ext(para_id: u32) -> sp_io::TestExternalities {
use parachain::{MsgQueue, Runtime, System};
let mut t = frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Runtime> {
balances: vec![
(PARA_ALICE.into(), INITIAL_BALANCE),
(parent_account_id(), INITIAL_BALANCE),
],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
sp_tracing::try_init_simple();
System::set_block_number(1);
MsgQueue::set_para_id(para_id.into());
});
ext
}
pub fn relay_ext() -> sp_io::TestExternalities {
use relay_chain::{Runtime, System};
let mut t = frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Runtime> {
balances: vec![
(ALICE, INITIAL_BALANCE),
(child_account_id(1), INITIAL_BALANCE),
(child_account_id(2), INITIAL_BALANCE),
],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| {
System::set_block_number(1);
});
ext
}
pub type RelayChainPalletXcm = pallet_xcm::Pallet<relay_chain::Runtime>;
pub type ParachainPalletXcm = pallet_xcm::Pallet<parachain::Runtime>;