Skip to content

Commit

Permalink
Set up emulated relay chains
Browse files Browse the repository at this point in the history
  • Loading branch information
seadanda committed Dec 13, 2023
1 parent eb1ad61 commit 1841f23
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "coretime-rococo-emulated-chain"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Coretime 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 }
coretime-rococo-runtime = { path = "../../../../../../runtimes/coretime/coretime-rococo" }
rococo-emulated-chain = { path = "../../../relays/rococo" }
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 coretime_rococo_runtime::{
CollatorSelectionConfig, ParachainInfoConfig, PolkadotXcmConfig, RuntimeGenesisConfig,
SessionConfig, SessionKeys, SystemConfig, WASM_BINARY,
};
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 = 1005;
pub const ED: Balance = parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;

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

build_genesis_storage(
&genesis_config,
WASM_BINARY.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 coretime_rococo_runtime::{
xcm_config::LocationToAccountId, AuraExt, Balances, Broker, ParachainInfo, PolkadotXcm,
XcmpQueue,
};
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
};

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

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,25 @@
[package]
name = "coretime-westend-emulated-chain"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Coretime Westend 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 }
coretime-westend-runtime = { path = "../../../../../../runtimes/coretime/coretime-westend" }
westend-emulated-chain = { path = "../../../relays/westend" }
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 coretime_westend_runtime::{
CollatorSelectionConfig, ParachainInfoConfig, PolkadotXcmConfig, RuntimeGenesisConfig,
SessionConfig, SessionKeys, SystemConfig, WASM_BINARY,
};
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 = 1005;
pub const ED: Balance = parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;

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

build_genesis_storage(
&genesis_config,
WASM_BINARY.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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 coretime_westend_runtime::{
xcm_config::LocationToAccountId, AuraExt, Balances, Broker, ParachainInfo, PolkadotXcm,
XcmpQueue,
};
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impls::Parachain, xcm_emulator::decl_test_parachains,
};

decl_test_parachains! {
pub struct CoretimeWestend {
genesis = genesis::genesis(),
on_init = {
AuraExt::on_initialize(1);
},
runtime = coretime_westend_runtime,
core = {
XcmpMessageHandler: XcmpQueue,
LocationToAccountId: LocationToAccountId,
ParachainInfo: ParachainInfo,
},
pallets = {
PolkadotXcm: PolkadotXcm,
Balances: Balances,
Broker: Broker,
}
},
}

impl_accounts_helpers_for_parachain!(CoretimeWestend);
impl_assert_events_helpers_for_parachain!(CoretimeWestend);

0 comments on commit 1841f23

Please sign in to comment.