Replicate e2e integration test as emulated (#2958)

* Allow functions to work over both parachains and relay chains

* additional references

* import

* backup

* refactoring para and relay traits

* use runtime crates to build types

* decouple ProcessMessage

* decouple ProcessMessage 2

* dmp and xcmp handlers decouple

* backup

* refactor done

* common int values working

* added global ext with mutex

* works for two mutex

* single mutex and remove condvar

* global test ext done

* failing moving test_ext because relay block num

* relay_block_number issue fixed

* backup

* Test working with assertions

* assertions get Test as arg

* DispatchArgs as generic

* clean up

* backup

* teleports for asset-hub-kusama done

* improve assert_expected_events macro

* rename Test generics

* check assertions for tuples

* test assertions redone

* reserve_transfer_assets done

* send transact done

* hrmp test for paras

* hrmp channels test done

* hrmp channels test done 2

* before modifying test dispatch

* reserve tests done & Test dispatch fixed

* reserve transfer local asset

* force_create_and_mint_asset

* force create and mint done

* tests done

* fix imports in common

* common events refactored

* add option to events attributes

* asset-hub-polkadot tests done

* asset-hub-westend half done

* relay chain events move to common

* remove failing send tests for asset-hub-westend

* added events to bridge-hub-rococo

* added events to collectives-polkadot

* cargo clean up

* fix asset-hub-westend tests

* ".git/.scripts/commands/fmt/fmt.sh"

* fix clippy

* ".git/.scripts/commands/fmt/fmt.sh"

* Removed unnecessary deps

* Extracted some commonality for Kusama/Polkadot (which will be reused also for BridgeHubs) (#2971)

* Extracted some commonality for Kusama/Polkadot (which will be reused also for BridgeHubs)

* AssetHubRococo should better use AssetHubKusama runtime

* add fund_account

---------

Co-authored-by: NachoPal <ignacio.palacios.santos@gmail.com>

* address comments

* rename event assertion helpers

* clean comments

* address comments 2

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: command-bot <>
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
Ignacio Palacios
2023-08-10 19:38:18 +02:00
committed by GitHub
parent e077bdd99f
commit eadfbca388
40 changed files with 5344 additions and 1300 deletions
@@ -1,121 +1,114 @@
pub use lazy_static;
pub mod constants;
pub mod impls;
pub use codec::Encode;
pub use constants::{
accounts::{ALICE, BOB},
asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama,
bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend,
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD,
};
use frame_support::{
assert_ok, instances::Instance1, parameter_types, sp_tracing, traits::fungibles::Inspect,
};
pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler};
use frame_support::{parameter_types, sp_io, sp_tracing};
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
pub use parachains_common::{AccountId, Balance};
pub use paste;
use polkadot_parachain::primitives::HrmpChannelId;
pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
pub use sp_core::{sr25519, storage::Storage, Get};
use xcm::prelude::*;
use xcm_emulator::{
decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains,
decl_test_sender_receiver_accounts_parameter_types, BridgeMessageHandler, Parachain,
RelayChain, TestExt,
assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains,
decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types,
helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, ParaId,
Parachain, RelayChain, TestExt,
};
pub use xcm::{
prelude::{
AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation,
OriginKind, Outcome, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight,
WeightLimit, WithdrawAsset, Xcm, X1,
},
v3::Error,
DoubleEncoded,
};
use xcm_executor::traits::ConvertLocation;
decl_test_relay_chains! {
#[api_version(5)]
pub struct Polkadot {
genesis = polkadot::genesis(),
on_init = (),
runtime = {
Runtime: polkadot_runtime::Runtime,
RuntimeOrigin: polkadot_runtime::RuntimeOrigin,
RuntimeCall: polkadot_runtime::RuntimeCall,
RuntimeEvent: polkadot_runtime::RuntimeEvent,
MessageQueue: polkadot_runtime::MessageQueue,
XcmConfig: polkadot_runtime::xcm_config::XcmConfig,
runtime = polkadot_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Polkadot>,
SovereignAccountOf: polkadot_runtime::xcm_config::SovereignAccountOf,
System: polkadot_runtime::System,
Balances: polkadot_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: polkadot_runtime::XcmPallet,
Balances: polkadot_runtime::Balances,
Hrmp: polkadot_runtime::Hrmp,
}
},
#[api_version(5)]
pub struct Kusama {
genesis = kusama::genesis(),
on_init = (),
runtime = {
Runtime: kusama_runtime::Runtime,
RuntimeOrigin: kusama_runtime::RuntimeOrigin,
RuntimeCall: kusama_runtime::RuntimeCall,
RuntimeEvent: kusama_runtime::RuntimeEvent,
MessageQueue: kusama_runtime::MessageQueue,
XcmConfig: kusama_runtime::xcm_config::XcmConfig,
runtime = kusama_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Kusama>,
SovereignAccountOf: kusama_runtime::xcm_config::SovereignAccountOf,
System: kusama_runtime::System,
Balances: kusama_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: kusama_runtime::XcmPallet,
Balances: kusama_runtime::Balances,
Hrmp: kusama_runtime::Hrmp,
}
},
#[api_version(5)]
pub struct Westend {
genesis = westend::genesis(),
on_init = (),
runtime = {
Runtime: westend_runtime::Runtime,
RuntimeOrigin: westend_runtime::RuntimeOrigin,
RuntimeCall: westend_runtime::RuntimeCall,
RuntimeEvent: westend_runtime::RuntimeEvent,
MessageQueue: westend_runtime::MessageQueue,
XcmConfig: westend_runtime::xcm_config::XcmConfig,
runtime = westend_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Westend>,
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
System: westend_runtime::System,
Balances: westend_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: westend_runtime::XcmPallet,
Sudo: westend_runtime::Sudo,
Balances: westend_runtime::Balances,
}
},
#[api_version(5)]
pub struct Rococo {
genesis = rococo::genesis(),
on_init = (),
runtime = {
Runtime: rococo_runtime::Runtime,
RuntimeOrigin: rococo_runtime::RuntimeOrigin,
RuntimeCall: rococo_runtime::RuntimeCall,
RuntimeEvent: rococo_runtime::RuntimeEvent,
MessageQueue: rococo_runtime::MessageQueue,
XcmConfig: rococo_runtime::xcm_config::XcmConfig,
runtime = rococo_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Rococo>,
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
System: rococo_runtime::System,
Balances: rococo_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: rococo_runtime::XcmPallet,
Sudo: rococo_runtime::Sudo,
Balances: rococo_runtime::Balances,
}
},
#[api_version(5)]
pub struct Wococo {
genesis = rococo::genesis(),
on_init = (),
runtime = {
Runtime: rococo_runtime::Runtime,
RuntimeOrigin: rococo_runtime::RuntimeOrigin,
RuntimeCall: rococo_runtime::RuntimeCall,
RuntimeEvent: rococo_runtime::RuntimeEvent,
MessageQueue: rococo_runtime::MessageQueue,
XcmConfig: rococo_runtime::xcm_config::XcmConfig,
runtime = rococo_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Wococo>,
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
System: rococo_runtime::System,
Balances: rococo_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: rococo_runtime::XcmPallet,
Sudo: rococo_runtime::Sudo,
Balances: rococo_runtime::Balances,
}
}
}
@@ -125,81 +118,74 @@ decl_test_parachains! {
pub struct AssetHubPolkadot {
genesis = asset_hub_polkadot::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_polkadot_runtime::Runtime,
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
runtime = asset_hub_polkadot_runtime,
core = {
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: asset_hub_polkadot_runtime::System,
Balances: asset_hub_polkadot_runtime::Balances,
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
Assets: asset_hub_polkadot_runtime::Assets,
Balances: asset_hub_polkadot_runtime::Balances,
}
},
pub struct Collectives {
genesis = collectives::genesis(),
on_init = (),
runtime = {
Runtime: collectives_polkadot_runtime::Runtime,
RuntimeOrigin: collectives_polkadot_runtime::RuntimeOrigin,
RuntimeCall: collectives_polkadot_runtime::RuntimeCall,
RuntimeEvent: collectives_polkadot_runtime::RuntimeEvent,
runtime = collectives_polkadot_runtime,
core = {
XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue,
DmpMessageHandler: collectives_polkadot_runtime::DmpQueue,
LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId,
System: collectives_polkadot_runtime::System,
Balances: collectives_polkadot_runtime::Balances,
ParachainSystem: collectives_polkadot_runtime::ParachainSystem,
ParachainInfo: collectives_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm,
Balances: collectives_polkadot_runtime::Balances,
}
},
pub struct BridgeHubPolkadot {
genesis = bridge_hub_polkadot::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_polkadot_runtime::Runtime,
RuntimeOrigin: bridge_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_polkadot_runtime::RuntimeEvent,
runtime = bridge_hub_polkadot_runtime,
core = {
XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_polkadot_runtime::System,
Balances: bridge_hub_polkadot_runtime::Balances,
ParachainSystem: bridge_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: bridge_hub_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm,
}
},
pub struct PenpalPolkadot {
genesis = penpal::genesis(penpal::PARA_ID),
pub struct PenpalPolkadotA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = {
Runtime: penpal_runtime::Runtime,
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
RuntimeCall: penpal_runtime::RuntimeCall,
RuntimeEvent: penpal_runtime::RuntimeEvent,
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
System: penpal_runtime::System,
Balances: penpal_runtime::Balances,
ParachainSystem: penpal_runtime::ParachainSystem,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
},
pub struct PenpalPolkadotB {
genesis = penpal::genesis(penpal::PARA_ID_B),
on_init = (),
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
@@ -208,62 +194,60 @@ decl_test_parachains! {
pub struct AssetHubKusama {
genesis = asset_hub_kusama::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_kusama_runtime::Runtime,
RuntimeOrigin: asset_hub_kusama_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_kusama_runtime::RuntimeCall,
RuntimeEvent: asset_hub_kusama_runtime::RuntimeEvent,
runtime = asset_hub_kusama_runtime,
core = {
XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue,
LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId,
System: asset_hub_kusama_runtime::System,
Balances: asset_hub_kusama_runtime::Balances,
ParachainSystem: asset_hub_kusama_runtime::ParachainSystem,
ParachainInfo: asset_hub_kusama_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm,
Assets: asset_hub_kusama_runtime::Assets,
ForeignAssets: asset_hub_kusama_runtime::Assets,
Balances: asset_hub_kusama_runtime::Balances,
}
},
pub struct BridgeHubKusama {
genesis = bridge_hub_kusama::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_kusama_runtime::Runtime,
RuntimeOrigin: bridge_hub_kusama_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_kusama_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_kusama_runtime::RuntimeEvent,
runtime = bridge_hub_kusama_runtime,
core = {
XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue,
LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_kusama_runtime::System,
Balances: bridge_hub_kusama_runtime::Balances,
ParachainSystem: bridge_hub_kusama_runtime::ParachainSystem,
ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm,
}
},
pub struct PenpalKusama {
genesis = penpal::genesis(penpal::PARA_ID),
pub struct PenpalKusamaA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = {
Runtime: penpal_runtime::Runtime,
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
RuntimeCall: penpal_runtime::RuntimeCall,
RuntimeEvent: penpal_runtime::RuntimeEvent,
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
System: penpal_runtime::System,
Balances: penpal_runtime::Balances,
ParachainSystem: penpal_runtime::ParachainSystem,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
},
pub struct PenpalKusamaB {
genesis = penpal::genesis(penpal::PARA_ID_B),
on_init = (),
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
@@ -272,44 +256,33 @@ decl_test_parachains! {
pub struct AssetHubWestend {
genesis = asset_hub_westend::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_westend_runtime::Runtime,
RuntimeOrigin: asset_hub_westend_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_westend_runtime::RuntimeCall,
RuntimeEvent: asset_hub_westend_runtime::RuntimeEvent,
runtime = asset_hub_westend_runtime,
core = {
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_westend_runtime::DmpQueue,
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
System: asset_hub_westend_runtime::System,
Balances: asset_hub_westend_runtime::Balances,
ParachainSystem: asset_hub_westend_runtime::ParachainSystem,
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
Balances: asset_hub_westend_runtime::Balances,
Assets: asset_hub_westend_runtime::Assets,
ForeignAssets: asset_hub_westend_runtime::ForeignAssets,
PoolAssets: asset_hub_westend_runtime::PoolAssets,
AssetConversion: asset_hub_westend_runtime::AssetConversion,
}
},
pub struct PenpalWestend {
genesis = penpal::genesis(penpal::PARA_ID),
pub struct PenpalWestendA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = {
Runtime: penpal_runtime::Runtime,
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
RuntimeCall: penpal_runtime::RuntimeCall,
RuntimeEvent: penpal_runtime::RuntimeEvent,
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
System: penpal_runtime::System,
Balances: penpal_runtime::Balances,
ParachainSystem: penpal_runtime::ParachainSystem,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
@@ -318,85 +291,78 @@ decl_test_parachains! {
pub struct BridgeHubRococo {
genesis = bridge_hub_rococo::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_rococo_runtime::Runtime,
RuntimeOrigin: bridge_hub_rococo_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_rococo_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_rococo_runtime::RuntimeEvent,
runtime = bridge_hub_rococo_runtime,
core = {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_rococo_runtime::DmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_rococo_runtime::System,
Balances: bridge_hub_rococo_runtime::Balances,
ParachainSystem: bridge_hub_rococo_runtime::ParachainSystem,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Balances: bridge_hub_rococo_runtime::Balances,
}
},
// AssetHubRococo (aka Rockmine/Rockmine2) mirrors AssetHubKusama
pub struct AssetHubRococo {
genesis = asset_hub_polkadot::genesis(),
genesis = asset_hub_kusama::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_polkadot_runtime::Runtime,
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: asset_hub_polkadot_runtime::System,
Balances: asset_hub_polkadot_runtime::Balances,
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
runtime = asset_hub_kusama_runtime,
core = {
XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue,
LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_kusama_runtime::ParachainInfo,
},
pallets_extra = {
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
Assets: asset_hub_polkadot_runtime::Assets,
pallets = {
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm,
Assets: asset_hub_kusama_runtime::Assets,
}
},
// Wococo Parachains
pub struct BridgeHubWococo {
genesis = bridge_hub_rococo::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_rococo_runtime::Runtime,
RuntimeOrigin: bridge_hub_rococo_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_rococo_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_rococo_runtime::RuntimeEvent,
runtime = bridge_hub_rococo_runtime,
core = {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_rococo_runtime::DmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_rococo_runtime::System,
Balances: bridge_hub_rococo_runtime::Balances,
ParachainSystem: bridge_hub_rococo_runtime::ParachainSystem,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
}
},
pub struct AssetHubWococo {
genesis = asset_hub_polkadot::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_polkadot_runtime::Runtime,
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
runtime = asset_hub_polkadot_runtime,
core = {
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: asset_hub_polkadot_runtime::System,
Balances: asset_hub_polkadot_runtime::Balances,
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
Assets: asset_hub_polkadot_runtime::Assets,
}
},
pub struct PenpalRococoA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
}
}
@@ -405,9 +371,10 @@ decl_test_networks! {
relay_chain = Polkadot,
parachains = vec![
AssetHubPolkadot,
PenpalPolkadot,
Collectives,
BridgeHubPolkadot,
PenpalPolkadotA,
PenpalPolkadotB,
],
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
// bridge = PolkadotKusamaMockBridge
@@ -417,8 +384,9 @@ decl_test_networks! {
relay_chain = Kusama,
parachains = vec![
AssetHubKusama,
PenpalKusama,
PenpalKusamaA,
BridgeHubKusama,
PenpalKusamaB,
],
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
// bridge = KusamaPolkadotMockBridge
@@ -428,7 +396,7 @@ decl_test_networks! {
relay_chain = Westend,
parachains = vec![
AssetHubWestend,
PenpalWestend,
PenpalWestendA,
],
bridge = ()
},
@@ -437,6 +405,7 @@ decl_test_networks! {
parachains = vec![
AssetHubRococo,
BridgeHubRococo,
PenpalRococoA,
],
bridge = RococoWococoMockBridge
},
@@ -474,6 +443,51 @@ decl_test_bridges! {
// }
}
// Polkadot implementation
impl_accounts_helpers_for_relay_chain!(Polkadot);
impl_assert_events_helpers_for_relay_chain!(Polkadot);
impl_hrmp_channels_helpers_for_relay_chain!(Polkadot);
// Kusama implementation
impl_accounts_helpers_for_relay_chain!(Kusama);
impl_assert_events_helpers_for_relay_chain!(Kusama);
impl_hrmp_channels_helpers_for_relay_chain!(Kusama);
// Westend implementation
impl_accounts_helpers_for_relay_chain!(Westend);
impl_assert_events_helpers_for_relay_chain!(Westend);
// Rococo implementation
impl_accounts_helpers_for_relay_chain!(Rococo);
impl_assert_events_helpers_for_relay_chain!(Rococo);
// Wococo implementation
impl_accounts_helpers_for_relay_chain!(Wococo);
impl_assert_events_helpers_for_relay_chain!(Wococo);
// AssetHubPolkadot implementation
impl_accounts_helpers_for_parachain!(AssetHubPolkadot);
impl_assets_helpers_for_parachain!(AssetHubPolkadot, Polkadot);
impl_assert_events_helpers_for_parachain!(AssetHubPolkadot);
// AssetHubKusama implementation
impl_accounts_helpers_for_parachain!(AssetHubKusama);
impl_assets_helpers_for_parachain!(AssetHubKusama, Kusama);
impl_assert_events_helpers_for_parachain!(AssetHubKusama);
// AssetHubWestend implementation
impl_accounts_helpers_for_parachain!(AssetHubWestend);
impl_assets_helpers_for_parachain!(AssetHubWestend, Westend);
impl_assert_events_helpers_for_parachain!(AssetHubWestend);
// Collectives implementation
impl_accounts_helpers_for_parachain!(Collectives);
impl_assert_events_helpers_for_parachain!(Collectives);
// BridgeHubRococo implementation
impl_accounts_helpers_for_parachain!(BridgeHubRococo);
impl_assert_events_helpers_for_parachain!(BridgeHubRococo);
decl_test_sender_receiver_accounts_parameter_types! {
// Relays
Polkadot { sender: ALICE, receiver: BOB },
@@ -495,7 +509,51 @@ decl_test_sender_receiver_accounts_parameter_types! {
BridgeHubRococo { sender: ALICE, receiver: BOB },
BridgeHubWococo { sender: ALICE, receiver: BOB },
// Penpals
PenpalPolkadot { sender: ALICE, receiver: BOB },
PenpalKusama { sender: ALICE, receiver: BOB },
PenpalWestend { sender: ALICE, receiver: BOB }
PenpalPolkadotA { sender: ALICE, receiver: BOB },
PenpalPolkadotB { sender: ALICE, receiver: BOB },
PenpalKusamaA { sender: ALICE, receiver: BOB },
PenpalKusamaB { sender: ALICE, receiver: BOB },
PenpalWestendA { sender: ALICE, receiver: BOB },
PenpalRococoA { sender: ALICE, receiver: BOB }
}
/// Helper method to build a XCM with a `Transact` instruction and paying for its execution
pub fn xcm_transact_paid_execution(
call: DoubleEncoded<()>,
origin_kind: OriginKind,
native_asset: MultiAsset,
beneficiary: AccountId,
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
let native_assets: MultiAssets = native_asset.clone().into();
VersionedXcm::from(Xcm(vec![
WithdrawAsset(native_assets),
BuyExecution { fees: native_asset, weight_limit },
Transact { require_weight_at_most, origin_kind, call },
RefundSurplus,
DepositAsset {
assets: All.into(),
beneficiary: MultiLocation {
parents: 0,
interior: X1(AccountId32 { network: None, id: beneficiary.into() }),
},
},
]))
}
/// Helper method to build a XCM with a `Transact` instruction without paying for its execution
pub fn xcm_transact_unpaid_execution(
call: DoubleEncoded<()>,
origin_kind: OriginKind,
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
let check_origin = None;
VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit, check_origin },
Transact { require_weight_at_most, origin_kind, call },
]))
}