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

Commit f75df2a

Browse files
NachoPalgilescopebkontur
authored
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 <[email protected]> * address comments * rename event assertion helpers * clean comments * address comments 2 * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: Giles Cope <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Branislav Kontur <[email protected]>
1 parent 934d029 commit f75df2a

File tree

40 files changed

+5349
-1305
lines changed

40 files changed

+5349
-1305
lines changed

Cargo.lock

Lines changed: 20 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ pallet-xcm = { default-features = false, git = "https://github.com/paritytech/po
2828

2929
# Cumulus
3030
parachains-common = { path = "../../../../common" }
31-
penpal-runtime = { path = "../../../../runtimes/testing/penpal" }
32-
asset-hub-kusama-runtime = { path = "../../../../runtimes/assets/asset-hub-kusama" }
31+
cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue" }
32+
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" }
33+
cumulus-pallet-parachain-system = { path = "../../../../../pallets/parachain-system" }
3334

3435
# Local
3536
xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" }

parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,89 @@
1616

1717
pub use codec::Encode;
1818
pub use frame_support::{
19-
assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect,
19+
assert_err, assert_ok,
20+
instances::Instance1,
21+
pallet_prelude::Weight,
22+
sp_runtime::{AccountId32, DispatchError, DispatchResult, MultiAddress},
23+
traits::{fungibles::Inspect, OriginTrait},
2024
};
2125
pub use integration_tests_common::{
2226
constants::{
2327
accounts::{ALICE, BOB},
28+
asset_hub_kusama::ED as ASSET_HUB_KUSAMA_ED,
2429
kusama::ED as KUSAMA_ED,
2530
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
2631
},
27-
AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender,
28-
BridgeHubKusama, BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender,
29-
BridgeHubPolkadot, BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender,
30-
Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet,
31-
KusamaPallet, KusamaReceiver, KusamaSender, PenpalKusama, PenpalKusamaReceiver,
32-
PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot,
32+
lazy_static::lazy_static,
33+
xcm_transact_paid_execution, xcm_transact_unpaid_execution, AssetHubKusama,
34+
AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, BridgeHubKusama,
35+
BridgeHubKusamaPallet, BridgeHubKusamaReceiver, BridgeHubKusamaSender, BridgeHubPolkadot,
36+
BridgeHubPolkadotPallet, BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, Collectives,
37+
CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaMockNet, KusamaPallet,
38+
KusamaReceiver, KusamaSender, PenpalKusamaA, PenpalKusamaAPallet, PenpalKusamaAReceiver,
39+
PenpalKusamaASender, PenpalKusamaB, PenpalKusamaBPallet, PenpalKusamaBReceiver,
40+
PenpalKusamaBSender, PenpalPolkadotA, PenpalPolkadotAReceiver, PenpalPolkadotASender, Polkadot,
3341
PolkadotMockNet, PolkadotPallet, PolkadotReceiver, PolkadotSender,
3442
};
43+
pub use parachains_common::{AccountId, Balance};
3544
pub use polkadot_core_primitives::InboundDownwardMessage;
45+
pub use polkadot_parachain::primitives::{HrmpChannelId, Id};
46+
pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
3647
pub use xcm::{
3748
prelude::*,
3849
v3::{Error, NetworkId::Kusama as KusamaId},
50+
DoubleEncoded,
3951
};
4052
pub use xcm_emulator::{
4153
assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold,
42-
Parachain as Para, RelayChain as Relay, TestExt,
54+
AccountId32Junction, Chain, ParaId, Parachain as Para, RelayChain as Relay, Test, TestArgs,
55+
TestContext, TestExt, TestExternalities,
4356
};
4457

58+
pub const ASSET_ID: u32 = 1;
59+
pub const ASSET_MIN_BALANCE: u128 = 1000;
60+
// `Assets` pallet index
61+
pub const ASSETS_PALLET_ID: u8 = 50;
62+
63+
pub type RelayToSystemParaTest = Test<Kusama, AssetHubKusama>;
64+
pub type SystemParaToRelayTest = Test<AssetHubKusama, Kusama>;
65+
pub type SystemParaToParaTest = Test<AssetHubKusama, PenpalKusamaA>;
66+
67+
/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests
68+
pub fn relay_test_args(amount: Balance) -> TestArgs {
69+
TestArgs {
70+
dest: Kusama::child_location_of(AssetHubKusama::para_id()),
71+
beneficiary: AccountId32Junction {
72+
network: None,
73+
id: AssetHubKusamaReceiver::get().into(),
74+
}
75+
.into(),
76+
amount,
77+
assets: (Here, amount).into(),
78+
asset_id: None,
79+
fee_asset_item: 0,
80+
weight_limit: WeightLimit::Unlimited,
81+
}
82+
}
83+
84+
/// Returns a `TestArgs` instance to de used for the System Parachain accross integraton tests
85+
pub fn system_para_test_args(
86+
dest: MultiLocation,
87+
beneficiary_id: AccountId32,
88+
amount: Balance,
89+
assets: MultiAssets,
90+
asset_id: Option<u32>,
91+
) -> TestArgs {
92+
TestArgs {
93+
dest,
94+
beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(),
95+
amount,
96+
assets,
97+
asset_id,
98+
fee_asset_item: 0,
99+
weight_limit: WeightLimit::Unlimited,
100+
}
101+
}
102+
45103
#[cfg(test)]
46104
mod tests;

0 commit comments

Comments
 (0)