Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create xcm emulator tests for People-Rococo #2373

Merged
merged 106 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 94 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
9de660b
create initial structure
0xmovses Nov 16, 2023
0f3d4a1
Update cumulus/parachains/integration-tests/emulated/chains/parachain…
0xmovses Nov 20, 2023
71eafe0
updates
0xmovses Nov 20, 2023
92d9d63
parachain set identity
0xmovses Nov 20, 2023
1908d75
assert has_idenity
0xmovses Nov 20, 2023
7d20153
reap identity
0xmovses Nov 20, 2023
dffefa1
updates xcm tests
0xmovses Nov 20, 2023
cebde91
assert deposit amount non zero
0xmovses Nov 20, 2023
84e6ed5
set identity zero deposit
0xmovses Nov 21, 2023
a762093
add test args
0xmovses Nov 21, 2023
2a970c2
".git/.scripts/commands/fmt/fmt.sh"
Nov 21, 2023
aeec8ef
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 22, 2023
319b3ae
address petrowski feedback
0xmovses Nov 22, 2023
13d9d18
assert on subs_of
0xmovses Nov 22, 2023
b92de0a
add asserts on parachain
0xmovses Nov 22, 2023
6275090
check unreserved amount
0xmovses Nov 22, 2023
9072f05
add xcm feature, cleanup
0xmovses Nov 22, 2023
10da8af
remove redundant comment
0xmovses Nov 22, 2023
b5e4b3e
".git/.scripts/commands/fmt/fmt.sh"
Nov 22, 2023
65da33e
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 22, 2023
386744f
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 22, 2023
a6312db
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 22, 2023
5e3e9a3
Update substrate/frame/identity/src/lib.rs
0xmovses Nov 22, 2023
e8e88d1
Update substrate/frame/identity/src/lib.rs
0xmovses Nov 22, 2023
41b3564
Update polkadot/runtime/rococo/src/lib.rs
0xmovses Nov 22, 2023
21ce617
Update polkadot/runtime/rococo/src/lib.rs
0xmovses Nov 22, 2023
1e2ab6d
add some printlns
0xmovses Nov 22, 2023
98cb721
assert parachain processes msg queue
0xmovses Nov 22, 2023
7670e4d
Update substrate/frame/identity/src/lib.rs
0xmovses Nov 22, 2023
e90f351
assert additional events
0xmovses Nov 22, 2023
9fbc89e
assert on inner enum vals
0xmovses Nov 23, 2023
72b38e2
".git/.scripts/commands/fmt/fmt.sh"
Nov 23, 2023
0d1c309
fmt
0xmovses Nov 23, 2023
7b35c9f
fmt
0xmovses Nov 23, 2023
472d203
assert IdentityMigrator events
0xmovses Nov 24, 2023
342454e
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 24, 2023
1bca9e7
Update cumulus/parachains/integration-tests/emulated/chains/parachain…
0xmovses Nov 24, 2023
c29d8f7
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 24, 2023
11d0a6a
version 0 cargo.lock
0xmovses Nov 24, 2023
880f611
Add filter, update weights
0xmovses Nov 27, 2023
3b3454c
update amounts and weights, all tests passing
0xmovses Nov 27, 2023
6d868e1
Update cumulus/parachains/integration-tests/emulated/chains/parachain…
0xmovses Nov 28, 2023
ee8d510
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 28, 2023
8f54f7b
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 28, 2023
b4e826e
updates
0xmovses Nov 28, 2023
12840ef
address pr feedback
0xmovses Nov 28, 2023
7ccfff3
add type aliases
0xmovses Nov 28, 2023
301fffe
fix conflicts
0xmovses Nov 28, 2023
dd8441f
".git/.scripts/commands/fmt/fmt.sh"
Nov 28, 2023
b313e18
typo
0xmovses Nov 28, 2023
8e9b251
clippy
0xmovses Nov 28, 2023
5ae4cd8
atleast an ED
0xmovses Nov 28, 2023
da2f38e
assert equality on exact
0xmovses Nov 28, 2023
4fc3e01
".git/.scripts/commands/fmt/fmt.sh"
Nov 28, 2023
f575356
create identities
0xmovses Nov 29, 2023
3902107
generalise asserts
0xmovses Nov 29, 2023
bc6a03e
check many instances
0xmovses Nov 29, 2023
58f8e77
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Nov 29, 2023
8abca7c
add comment
0xmovses Nov 29, 2023
0e2ddc1
add petrowski cases
0xmovses Nov 29, 2023
512e3a1
updates cleanup
0xmovses Nov 29, 2023
3985fab
reduce code duplication
0xmovses Nov 30, 2023
239e297
Merge branch 'joe-people-chain' into 0xmovses-people-xcm-tests
0xmovses Nov 30, 2023
3d262dd
use calc_remote_deposit
0xmovses Nov 30, 2023
348b9c4
assert and calculate on remote deposit
0xmovses Nov 30, 2023
872e454
remove redundant comment
0xmovses Nov 30, 2023
363ad04
clean
0xmovses Nov 30, 2023
c394638
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Dec 1, 2023
dbcd0bb
updates
0xmovses Dec 1, 2023
0c51fc4
Revert "updates"
0xmovses Dec 1, 2023
51a21a7
add Subs cases, refactor, petrowski feedback
0xmovses Dec 1, 2023
c2ca2ab
cleanup
0xmovses Dec 1, 2023
97a59fc
integrate seadanda feedback and further refactors
0xmovses Dec 1, 2023
9bcaffb
improve Identity::new
0xmovses Dec 1, 2023
0877093
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Dec 1, 2023
5c4fa6a
integrate petrowski feedback
0xmovses Dec 1, 2023
d73f6fe
call n times for with n new accounts
0xmovses Dec 1, 2023
83a5e70
create set_subs, update assertions
0xmovses Dec 1, 2023
8d23635
update comment
0xmovses Dec 1, 2023
5861ab5
total_deposit from subs variant
0xmovses Dec 1, 2023
5ba20bd
fix conflict
0xmovses Dec 1, 2023
0a44a21
small cleanups
0xmovses Dec 1, 2023
c5f065f
remove unneeded match
0xmovses Dec 1, 2023
37845fe
add all 12 cases
0xmovses Dec 1, 2023
dca8618
use default
0xmovses Dec 1, 2023
72829cb
generalise calc deposit
0xmovses Dec 2, 2023
e3a9f45
Tweaks to emulator People testing (#2595)
0xmovses Dec 4, 2023
6b015f9
integrate aguirre feedback
0xmovses Dec 4, 2023
bc86d0d
typo
0xmovses Dec 4, 2023
84fa2b1
improve doc comment
0xmovses Dec 4, 2023
ee7c5a9
Update cumulus/parachains/integration-tests/emulated/common/src/lib.rs
0xmovses Dec 4, 2023
342165f
Update cumulus/parachains/integration-tests/emulated/common/src/lib.rs
0xmovses Dec 4, 2023
cb3f892
impl relay para methods for TestArgs
0xmovses Dec 4, 2023
5582178
refactors
0xmovses Dec 4, 2023
dca66bf
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Dec 4, 2023
860c647
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Dec 4, 2023
76f4400
Update cumulus/parachains/integration-tests/emulated/tests/people/peo…
0xmovses Dec 4, 2023
149cae4
Update cumulus/parachains/integration-tests/emulated/common/src/impls.rs
0xmovses Dec 4, 2023
bc66fcd
Update substrate/frame/identity/src/lib.rs
0xmovses Dec 4, 2023
4a9cb21
integrate seadanda feedback, remove unused
0xmovses Dec 4, 2023
b2dddf8
update feature name
0xmovses Dec 4, 2023
bd4183d
".git/.scripts/commands/fmt/fmt.sh"
Dec 4, 2023
8083b9e
wrong method name
0xmovses Dec 4, 2023
3d9d09f
Apply suggestions from code review
joepetrowski Dec 5, 2023
1d7d1dd
Merge branch 'joe-people-chain' into 0xmovses-people-xcm-tests
joepetrowski Dec 5, 2023
b33d317
Update cumulus/xcm/xcm-emulator/src/lib.rs
joepetrowski Dec 5, 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
44 changes: 44 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,26 @@ members = [
"cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal",
"cumulus/parachains/integration-tests/emulated/chains/relays/rococo",
"cumulus/parachains/integration-tests/emulated/chains/relays/rococo",
"cumulus/parachains/integration-tests/emulated/chains/relays/westend",
"cumulus/parachains/integration-tests/emulated/chains/relays/westend",
"cumulus/parachains/integration-tests/emulated/common",
"cumulus/parachains/integration-tests/emulated/common",
"cumulus/parachains/integration-tests/emulated/networks/rococo-system",
"cumulus/parachains/integration-tests/emulated/networks/rococo-westend-system",
"cumulus/parachains/integration-tests/emulated/networks/westend-system",
"cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo",
"cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo",
"cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend",
"cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend",
"cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo",
"cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo",
"cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend",
"cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend",
"cumulus/parachains/integration-tests/emulated/tests/people/people-rococo",
"cumulus/parachains/pallets/collective-content",
"cumulus/parachains/pallets/parachain-info",
"cumulus/parachains/pallets/ping",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "people-rococo-emulated-chain"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "People Rococo emulated chain"
publish = false

[dependencies]
serde_json = "1.0.104"

# Substrate
sp-core = { path = "../../../../../../../../substrate/primitives/core", default-features = false }
sp-runtime = { path = "../../../../../../../../substrate/primitives/runtime", default-features = false }
frame-support = { path = "../../../../../../../../substrate/frame/support", default-features = false }

# Polakadot
parachains-common = { path = "../../../../../../../parachains/common" }

# Cumulus
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
people-rococo-runtime = { path = "../../../../../../runtimes/people/people-rococo" }
rococo-emulated-chain = { path = "../../../relays/rococo" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Substrate
use sp_core::storage::Storage;

// Cumulus
0xmovses marked this conversation as resolved.
Show resolved Hide resolved
use cumulus_primitives_core::ParaId;
use emulated_integration_tests_common::{build_genesis_storage, collators, SAFE_XCM_VERSION};
use parachains_common::Balance;

pub const PARA_ID: u32 = 1004;
pub const ED: Balance = parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;

pub fn genesis() -> Storage {
let genesis_config = people_rococo_runtime::RuntimeGenesisConfig {
system: people_rococo_runtime::SystemConfig::default(),
parachain_info: people_rococo_runtime::ParachainInfoConfig {
parachain_id: ParaId::from(PARA_ID),
..Default::default()
},
collator_selection: people_rococo_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: people_rococo_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
people_rococo_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: people_rococo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};
liamaharon marked this conversation as resolved.
Show resolved Hide resolved

build_genesis_storage(
&genesis_config,
people_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub mod genesis;

// Substrate
use frame_support::traits::OnInitialize;

// Cumulus
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
};

// PeopleRococo Parachain declaration
decl_test_parachains! {
pub struct PeopleRococo {
genesis = genesis::genesis(),
on_init = {
people_rococo_runtime::AuraExt::on_initialize(1);
},
runtime = people_rococo_runtime,
core = {
XcmpMessageHandler: people_rococo_runtime::XcmpQueue,
LocationToAccountId: people_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: people_rococo_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: people_rococo_runtime::PolkadotXcm,
Balances: people_rococo_runtime::Balances,
Identity: people_rococo_runtime::Identity,
IdentityMigrator: people_rococo_runtime::IdentityMigrator,
}
},
}

// PeopleRococo implementation
impl_accounts_helpers_for_parachain!(PeopleRococo);
impl_assert_events_helpers_for_parachain!(PeopleRococo);
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ decl_test_relay_chains! {
Sudo: rococo_runtime::Sudo,
Balances: rococo_runtime::Balances,
Hrmp: rococo_runtime::Hrmp,
Identity: rococo_runtime::Identity,
IdentityMigrator: rococo_runtime::IdentityMigrator,
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain {
);
}

/// Asserts a XCM message is sent
/// Asserts an XCM program is sent.
pub fn assert_xcm_pallet_sent() {
$crate::impls::assert_expected_events!(
Self,
Expand All @@ -250,7 +250,8 @@ macro_rules! impl_assert_events_helpers_for_relay_chain {
);
}

/// Asserts a XCM from System Parachain is succesfully received and proccessed
/// Asserts an XCM program from a System Parachain is succesfully received and
/// proccessed within expectations.
0xmovses marked this conversation as resolved.
Show resolved Hide resolved
pub fn assert_ump_queue_processed(
expected_success: bool,
expected_id: Option<$crate::impls::ParaId>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ use sp_runtime::{
};

// Polakdot
use parachains_common::BlockNumber;
use parachains_common::{Balance, BlockNumber};
use polkadot_runtime_parachains::configuration::HostConfiguration;
use xcm;
use xcm::prelude::{
AccountId32 as AccountId32Junction, Here, MultiAssets, MultiLocation, WeightLimit,
};

// Cumulus
use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId};
use polkadot_primitives::{AssignmentId, ValidatorId};
use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy;
use sp_core::crypto::AccountId32;
use xcm_emulator::TestArgs;

pub const XCM_V2: u32 = 2;
pub const XCM_V3: u32 = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ emulated-integration-tests-common = { path = "../../common", default-features =
rococo-emulated-chain = { path = "../../chains/relays/rococo" }
asset-hub-rococo-emulated-chain = { path = "../../chains/parachains/assets/asset-hub-rococo" }
bridge-hub-rococo-emulated-chain = { path = "../../chains/parachains/bridges/bridge-hub-rococo" }
people-rococo-emulated-chain = { path = "../../chains/parachains/people/people-rococo" }
penpal-emulated-chain = { path = "../../chains/parachains/testing/penpal" }
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
pub use asset_hub_rococo_emulated_chain;
pub use bridge_hub_rococo_emulated_chain;
pub use penpal_emulated_chain;
pub use people_rococo_emulated_chain;
pub use rococo_emulated_chain;

use asset_hub_rococo_emulated_chain::AssetHubRococo;
use bridge_hub_rococo_emulated_chain::BridgeHubRococo;
use penpal_emulated_chain::{PenpalA, PenpalB};
use people_rococo_emulated_chain::PeopleRococo;
use rococo_emulated_chain::Rococo;

// Cumulus
Expand All @@ -37,6 +39,7 @@ decl_test_networks! {
BridgeHubRococo,
PenpalA,
PenpalB,
PeopleRococo,
],
bridge = ()
},
Expand All @@ -47,5 +50,6 @@ decl_test_sender_receiver_accounts_parameter_types! {
AssetHubRococoPara { sender: ALICE, receiver: BOB },
BridgeHubRococoPara { sender: ALICE, receiver: BOB },
PenpalAPara { sender: ALICE, receiver: BOB },
PenpalBPara { sender: ALICE, receiver: BOB }
PenpalBPara { sender: ALICE, receiver: BOB },
PeopleRococoPara { sender: ALICE, receiver: BOB }
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,5 @@ pub type SystemParaToRelayTest = Test<AssetHubRococo, Rococo>;
pub type SystemParaToParaTest = Test<AssetHubRococo, PenpalA>;
pub type ParaToSystemParaTest = Test<PenpalA, AssetHubRococo>;

/// Returns a `TestArgs` instance to be used for the Relay Chain across integration tests
pub fn relay_test_args(
dest: MultiLocation,
beneficiary_id: AccountId32,
amount: Balance,
) -> TestArgs {
TestArgs {
dest,
beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(),
amount,
assets: (Here, amount).into(),
asset_id: None,
fee_asset_item: 0,
weight_limit: WeightLimit::Unlimited,
}
}

/// Returns a `TestArgs` instance to be used by parachains across integration tests
pub fn para_test_args(
dest: MultiLocation,
beneficiary_id: AccountId32,
amount: Balance,
assets: MultiAssets,
asset_id: Option<u32>,
fee_asset_item: u32,
) -> TestArgs {
TestArgs {
dest,
beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(),
amount,
assets,
asset_id,
fee_asset_item,
weight_limit: WeightLimit::Unlimited,
}
}

#[cfg(test)]
mod tests;
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
let test_args = TestContext {
sender: RococoSender::get(),
receiver: PenpalAReceiver::get(),
args: relay_test_args(destination, beneficiary_id, amount_to_send),
args: TestArgs::new_relay(destination, beneficiary_id, amount_to_send),
};

let mut test = RelayToParaTest::new(test_args);
Expand Down Expand Up @@ -319,7 +319,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
let test_args = TestContext {
sender: AssetHubRococoSender::get(),
receiver: PenpalAReceiver::get(),
args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0),
};

let mut test = SystemParaToParaTest::new(test_args);
Expand Down Expand Up @@ -363,7 +363,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let test_args = TestContext {
sender: PenpalASender::get(),
receiver: AssetHubRococoReceiver::get(),
args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
args: TestArgs::new_para(destination, beneficiary_id, amount_to_send, assets, None, 0),
};

let mut test = ParaToSystemParaTest::new(test_args);
Expand Down Expand Up @@ -443,7 +443,7 @@ fn reserve_transfer_assets_from_system_para_to_para() {
let para_test_args = TestContext {
sender: AssetHubRococoSender::get(),
receiver: PenpalAReceiver::get(),
args: para_test_args(
args: TestArgs::new_para(
destination,
beneficiary_id,
asset_amount_to_send,
Expand Down
Loading