Skip to content

Commit

Permalink
Backport claim assets tests from polkadot-fellows repo (paritytech#4930)
Browse files Browse the repository at this point in the history
# Issue
[Backport integration tests for claim assets to the polkadot-sdk from
polkadot-fellows repo
paritytech#4892](paritytech#4892)
# Description
For the first time to contribute this project, I just finished part and
make sure everything is ok.
- [x] backport [claim_assets test
case](https://github.com/polkadot-fellows/runtimes/blob/main/integration-tests/emulated/tests/assets/asset-hub-kusama/src/tests/claim_assets.rs)
to the polkadot-sdk testnet integration tests
- [x] backport macro
[test_chain_can_claim_assets](https://github.com/polkadot-fellows/runtimes/blob/main/integration-tests/emulated/helpers/src/lib.rs#L218)
from fellows repo
- [ ] when merged to polkadot-sdk and released, make sure that it is
propagated to the fellows repo:
polkadot-fellows/runtimes#363
- [x] backport and align other macros/test-cases from
https://github.com/polkadot-fellows/runtimes/blob/8ec28f96eeb30fbba30d29006d75e1a3fa1cea1c/integration-tests/emulated/helpers/src/lib.rs#L31-L33

---------

Co-authored-by: Zihan Zhao <[email protected]>
Co-authored-by: command-bot <>
Co-authored-by: Adrian Catangiu <[email protected]>
Co-authored-by: Francisco Aguirre <[email protected]>
  • Loading branch information
4 people authored Jul 19, 2024
1 parent b01ef04 commit d16af0b
Show file tree
Hide file tree
Showing 46 changed files with 1,170 additions and 14 deletions.
62 changes: 62 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ members = [
"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/collectives/collectives-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/people/people-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal",
Expand All @@ -104,6 +106,8 @@ members = [
"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/collectives/collectives-westend",
"cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-rococo",
"cumulus/parachains/integration-tests/emulated/tests/coretime/coretime-westend",
"cumulus/parachains/integration-tests/emulated/tests/people/people-rococo",
"cumulus/parachains/integration-tests/emulated/tests/people/people-westend",
"cumulus/parachains/pallets/collective-content",
Expand Down Expand Up @@ -667,7 +671,9 @@ colored = { version = "2.0.4" }
comfy-table = { version = "7.1.0", default-features = false }
console = { version = "0.15.8" }
contracts-rococo-runtime = { path = "cumulus/parachains/runtimes/contracts/contracts-rococo" }
coretime-rococo-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-rococo" }
coretime-rococo-runtime = { path = "cumulus/parachains/runtimes/coretime/coretime-rococo" }
coretime-westend-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/parachains/coretime/coretime-westend" }
coretime-westend-runtime = { path = "cumulus/parachains/runtimes/coretime/coretime-westend" }
cpu-time = { version = "1.0.0" }
criterion = { version = "0.5.1", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod genesis;

pub use bridge_hub_rococo_runtime::{
xcm_config::XcmConfig as BridgeHubRococoXcmConfig, EthereumBeaconClient, EthereumInboundQueue,
ExistentialDeposit as BridgeHubRococoExistentialDeposit,
RuntimeOrigin as BridgeHubRococoRuntimeOrigin,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

pub mod genesis;

pub use bridge_hub_westend_runtime::xcm_config::XcmConfig as BridgeHubWestendXcmConfig;
pub use bridge_hub_westend_runtime::{
xcm_config::XcmConfig as BridgeHubWestendXcmConfig,
ExistentialDeposit as BridgeHubWestendExistentialDeposit,
};

// Substrate
use frame_support::traits::OnInitialize;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "coretime-rococo-emulated-chain"
version = "0.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Coretime Rococo emulated chain"
publish = false

[lints]
workspace = true

[dependencies]

# Substrate
sp-core = { workspace = true }
frame-support = { workspace = true }

# Cumulus
parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true }
coretime-rococo-runtime = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }
testnet-parachains-constants = { features = ["rococo"], workspace = true, default-features = true }
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
};
use parachains_common::Balance;

pub const PARA_ID: u32 = 1005;
pub const ED: Balance = testnet_parachains_constants::rococo::currency::EXISTENTIAL_DEPOSIT;

pub fn genesis() -> Storage {
let genesis_config = coretime_rococo_runtime::RuntimeGenesisConfig {
system: coretime_rococo_runtime::SystemConfig::default(),
balances: coretime_rococo_runtime::BalancesConfig {
balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(),
},
parachain_info: coretime_rococo_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: coretime_rococo_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: coretime_rococo_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
coretime_rococo_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: coretime_rococo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
coretime_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,53 @@
// 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 use coretime_rococo_runtime;

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,
};

// CoretimeRococo Parachain declaration
decl_test_parachains! {
pub struct CoretimeRococo {
genesis = genesis::genesis(),
on_init = {
coretime_rococo_runtime::AuraExt::on_initialize(1);
},
runtime = coretime_rococo_runtime,
core = {
XcmpMessageHandler: coretime_rococo_runtime::XcmpQueue,
LocationToAccountId: coretime_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: coretime_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: coretime_rococo_runtime::PolkadotXcm,
Balances: coretime_rococo_runtime::Balances,
Broker: coretime_rococo_runtime::Broker,
}
},
}

// CoretimeRococo implementation
impl_accounts_helpers_for_parachain!(CoretimeRococo);
impl_assert_events_helpers_for_parachain!(CoretimeRococo);
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "coretime-westend-emulated-chain"
version = "0.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Coretime Westend emulated chain"
publish = false

[lints]
workspace = true

[dependencies]

# Substrate
sp-core = { workspace = true }
frame-support = { workspace = true }

# Cumulus
parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true }
coretime-westend-runtime = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }
testnet-parachains-constants = { features = ["westend"], workspace = true, default-features = true }
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
};
use parachains_common::Balance;

pub const PARA_ID: u32 = 1005;
pub const ED: Balance = testnet_parachains_constants::westend::currency::EXISTENTIAL_DEPOSIT;

pub fn genesis() -> Storage {
let genesis_config = coretime_westend_runtime::RuntimeGenesisConfig {
system: coretime_westend_runtime::SystemConfig::default(),
balances: coretime_westend_runtime::BalancesConfig {
balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(),
},
parachain_info: coretime_westend_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: coretime_westend_runtime::CollatorSelectionConfig {
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: coretime_westend_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
coretime_westend_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: coretime_westend_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
coretime_westend_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
)
}
Loading

0 comments on commit d16af0b

Please sign in to comment.