feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
[package]
|
||||
name = "coretime-pezkuwichain-integration-tests"
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
description = "Coretime Pezkuwichain runtime integration tests with xcm-emulator"
|
||||
publish = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
# Bizinikiwi
|
||||
pezframe-support = { workspace = true }
|
||||
pezpallet-broker = { workspace = true, default-features = true }
|
||||
pezpallet-message-queue = { workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
|
||||
# Pezkuwi
|
||||
pezkuwi-runtime-teyrchains = { workspace = true, default-features = true }
|
||||
pezkuwichain-runtime-constants = { workspace = true, default-features = true }
|
||||
xcm = { workspace = true }
|
||||
|
||||
# Pezcumulus
|
||||
pezcumulus-pezpallet-teyrchain-system = { workspace = true, default-features = true }
|
||||
emulated-integration-tests-common = { workspace = true }
|
||||
pezkuwichain-system-emulated-network = { workspace = true }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
"pezcumulus-pezpallet-teyrchain-system/runtime-benchmarks",
|
||||
"emulated-integration-tests-common/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezpallet-broker/runtime-benchmarks",
|
||||
"pezpallet-message-queue/runtime-benchmarks",
|
||||
"pezkuwi-runtime-teyrchains/runtime-benchmarks",
|
||||
"pezkuwichain-runtime-constants/runtime-benchmarks",
|
||||
"pezkuwichain-system-emulated-network/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"xcm/runtime-benchmarks",
|
||||
]
|
||||
+51
@@ -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.
|
||||
|
||||
#[cfg(test)]
|
||||
mod imports {
|
||||
|
||||
// Bizinikiwi
|
||||
pub(crate) use pezframe_support::assert_ok;
|
||||
|
||||
// Pezkuwi
|
||||
pub(crate) use xcm::{latest::PEZKUWICHAIN_GENESIS_HASH, prelude::*};
|
||||
|
||||
// Pezcumulus
|
||||
pub(crate) use emulated_integration_tests_common::xcm_emulator::{
|
||||
assert_expected_events, Chain, TestExt, Teyrchain,
|
||||
};
|
||||
pub(crate) use pezkuwichain_system_emulated_network::{
|
||||
asset_hub_pezkuwichain_emulated_chain::genesis::ED as ASSET_HUB_PEZKUWICHAIN_ED,
|
||||
coretime_pezkuwichain_emulated_chain::{
|
||||
coretime_pezkuwichain_runtime::ExistentialDeposit as CoretimePezkuwichainExistentialDeposit,
|
||||
genesis::ED as CORETIME_PEZKUWICHAIN_ED,
|
||||
CoretimePezkuwichainParaPallet as CoretimePezkuwichainPallet,
|
||||
},
|
||||
pezkuwichain_emulated_chain::{
|
||||
genesis::ED as PEZKUWICHAIN_ED, PezkuwichainRelayPallet as PezkuwichainPallet,
|
||||
},
|
||||
AssetHubPezkuwichainPara as AssetHubPezkuwichain,
|
||||
AssetHubPezkuwichainParaReceiver as AssetHubPezkuwichainReceiver,
|
||||
AssetHubPezkuwichainParaSender as AssetHubPezkuwichainSender,
|
||||
CoretimePezkuwichainPara as CoretimePezkuwichain,
|
||||
CoretimePezkuwichainParaReceiver as CoretimePezkuwichainReceiver,
|
||||
CoretimePezkuwichainParaSender as CoretimePezkuwichainSender,
|
||||
PezkuwichainRelay as Pezkuwichain, PezkuwichainRelayReceiver as PezkuwichainReceiver,
|
||||
PezkuwichainRelaySender as PezkuwichainSender,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// 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.
|
||||
|
||||
//! Tests related to claiming assets trapped during XCM execution.
|
||||
|
||||
use crate::imports::*;
|
||||
|
||||
use emulated_integration_tests_common::test_chain_can_claim_assets;
|
||||
|
||||
#[test]
|
||||
fn assets_can_be_claimed() {
|
||||
let amount = CoretimePezkuwichainExistentialDeposit::get();
|
||||
let assets: Assets = (Parent, amount).into();
|
||||
|
||||
test_chain_can_claim_assets!(
|
||||
CoretimePezkuwichain,
|
||||
RuntimeCall,
|
||||
NetworkId::ByGenesis(PEZKUWICHAIN_GENESIS_HASH),
|
||||
assets,
|
||||
amount
|
||||
);
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
// 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.
|
||||
|
||||
use crate::imports::*;
|
||||
use pezframe_support::traits::OnInitialize;
|
||||
use pezpallet_broker::{ConfigRecord, Configuration, CoreAssignment, CoreMask, ScheduleItem};
|
||||
use pezkuwichain_runtime_constants::system_teyrchain::coretime::TIMESLICE_PERIOD;
|
||||
use pezkuwichain_system_emulated_network::pezkuwichain_emulated_chain::pezkuwichain_runtime::Dmp;
|
||||
use pezsp_runtime::Perbill;
|
||||
|
||||
#[test]
|
||||
fn transact_hardcoded_weights_are_sane() {
|
||||
// There are three transacts with hardcoded weights sent from the Coretime Chain to the Relay
|
||||
// Chain across the CoretimeInterface which are triggered at various points in the sales cycle.
|
||||
// - Request core count - triggered directly by `start_sales` or `request_core_count`
|
||||
// extrinsics.
|
||||
// - Request revenue info - triggered when each timeslice is committed.
|
||||
// - Assign core - triggered when an entry is encountered in the workplan for the next
|
||||
// timeslice.
|
||||
|
||||
// RuntimeEvent aliases to avoid warning from usage of qualified paths in assertions due to
|
||||
// <https://github.com/rust-lang/rust/issues/86935>
|
||||
type CoretimeEvent = <CoretimePezkuwichain as Chain>::RuntimeEvent;
|
||||
type RelayEvent = <Pezkuwichain as Chain>::RuntimeEvent;
|
||||
|
||||
Pezkuwichain::execute_with(|| {
|
||||
Dmp::make_teyrchain_reachable(CoretimePezkuwichain::para_id());
|
||||
});
|
||||
|
||||
// Reserve a workload, configure broker and start sales.
|
||||
CoretimePezkuwichain::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround as we need `on_initialize` to tick things
|
||||
// along and have no concept of time passing otherwise.
|
||||
<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::on_initialize(
|
||||
<CoretimePezkuwichain as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
let coretime_root_origin = <CoretimePezkuwichain as Chain>::RuntimeOrigin::root();
|
||||
|
||||
// Create and populate schedule with the worst case assignment on this core.
|
||||
let mut schedule = Vec::new();
|
||||
for i in 0..80 {
|
||||
schedule.push(ScheduleItem {
|
||||
mask: CoreMask::void().set(i),
|
||||
assignment: CoreAssignment::Task(2000 + i),
|
||||
})
|
||||
}
|
||||
|
||||
assert_ok!(<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::reserve(
|
||||
coretime_root_origin.clone(),
|
||||
schedule.try_into().expect("Vector is within bounds."),
|
||||
));
|
||||
|
||||
// Configure broker and start sales.
|
||||
let config = ConfigRecord {
|
||||
advance_notice: 1,
|
||||
interlude_length: 1,
|
||||
leadin_length: 2,
|
||||
region_length: 1,
|
||||
ideal_bulk_proportion: Perbill::from_percent(40),
|
||||
limit_cores_offered: None,
|
||||
renewal_bump: Perbill::from_percent(2),
|
||||
contribution_timeout: 1,
|
||||
};
|
||||
assert_ok!(<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::configure(
|
||||
coretime_root_origin.clone(),
|
||||
config
|
||||
));
|
||||
assert_ok!(<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::start_sales(
|
||||
coretime_root_origin,
|
||||
100,
|
||||
0
|
||||
));
|
||||
assert_eq!(
|
||||
pezpallet_broker::Status::<<CoretimePezkuwichain as Chain>::Runtime>::get()
|
||||
.unwrap()
|
||||
.core_count,
|
||||
1
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimePezkuwichain,
|
||||
vec![
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::ReservationMade { .. }
|
||||
) => {},
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::CoreCountRequested { core_count: 1 }
|
||||
) => {},
|
||||
CoretimeEvent::TeyrchainSystem(
|
||||
cumulus_pallet_teyrchain_system::Event::UpwardMessageSent { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check that the request_core_count message was processed successfully. This will fail if the
|
||||
// weights are misconfigured.
|
||||
Pezkuwichain::execute_with(|| {
|
||||
Pezkuwichain::assert_ump_queue_processed(true, Some(CoretimePezkuwichain::para_id()), None);
|
||||
|
||||
assert_expected_events!(
|
||||
Pezkuwichain,
|
||||
vec![
|
||||
RelayEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Keep track of the relay chain block number so we can fast forward while still checking the
|
||||
// right block.
|
||||
let mut block_number_cursor =
|
||||
Pezkuwichain::ext_wrapper(<Pezkuwichain as Chain>::System::block_number);
|
||||
|
||||
let config = CoretimePezkuwichain::ext_wrapper(|| {
|
||||
Configuration::<<CoretimePezkuwichain as Chain>::Runtime>::get()
|
||||
.expect("Pallet was configured earlier.")
|
||||
});
|
||||
|
||||
// Now run up to the block before the sale is rotated.
|
||||
while block_number_cursor < TIMESLICE_PERIOD - config.advance_notice - 1 {
|
||||
CoretimePezkuwichain::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::on_initialize(
|
||||
<CoretimePezkuwichain as Chain>::System::block_number(),
|
||||
);
|
||||
});
|
||||
|
||||
Pezkuwichain::ext_wrapper(|| {
|
||||
block_number_cursor = <Pezkuwichain as Chain>::System::block_number();
|
||||
});
|
||||
}
|
||||
|
||||
// In this block we trigger assign core.
|
||||
CoretimePezkuwichain::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::on_initialize(
|
||||
<CoretimePezkuwichain as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimePezkuwichain,
|
||||
vec![
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::SaleInitialized { .. }
|
||||
) => {},
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::CoreAssigned { .. }
|
||||
) => {},
|
||||
CoretimeEvent::TeyrchainSystem(
|
||||
cumulus_pallet_teyrchain_system::Event::UpwardMessageSent { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check that the assign_core message was processed successfully.
|
||||
// This will fail if the weights are misconfigured.
|
||||
Pezkuwichain::execute_with(|| {
|
||||
Pezkuwichain::assert_ump_queue_processed(true, Some(CoretimePezkuwichain::para_id()), None);
|
||||
|
||||
assert_expected_events!(
|
||||
Pezkuwichain,
|
||||
vec![
|
||||
RelayEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
RelayEvent::Coretime(
|
||||
pezkuwi_runtime_teyrchains::coretime::Event::CoreAssigned { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// In this block we trigger request revenue.
|
||||
CoretimePezkuwichain::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::on_initialize(
|
||||
<CoretimePezkuwichain as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimePezkuwichain,
|
||||
vec![
|
||||
CoretimeEvent::TeyrchainSystem(
|
||||
cumulus_pallet_teyrchain_system::Event::UpwardMessageSent { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check that the request_revenue_info_at message was processed successfully.
|
||||
// This will fail if the weights are misconfigured.
|
||||
Pezkuwichain::execute_with(|| {
|
||||
Pezkuwichain::assert_ump_queue_processed(true, Some(CoretimePezkuwichain::para_id()), None);
|
||||
|
||||
assert_expected_events!(
|
||||
Pezkuwichain,
|
||||
vec![
|
||||
RelayEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Here we receive and process the notify_revenue XCM with zero revenue.
|
||||
CoretimePezkuwichain::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimePezkuwichain as CoretimePezkuwichainPallet>::Broker::on_initialize(
|
||||
<CoretimePezkuwichain as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimePezkuwichain,
|
||||
vec![
|
||||
CoretimeEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
// Zero revenue in first timeslice so history is immediately dropped.
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::HistoryDropped { when: 0, revenue: 0 }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// 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.
|
||||
|
||||
mod claim_assets;
|
||||
mod coretime_interface;
|
||||
mod teleport;
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
// 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.
|
||||
|
||||
use crate::imports::*;
|
||||
use emulated_integration_tests_common::{
|
||||
test_relay_is_trusted_teleporter, test_teyrchain_is_trusted_teleporter,
|
||||
test_teyrchain_is_trusted_teleporter_for_relay,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn teleport_via_limited_teleport_assets_from_and_to_relay() {
|
||||
let amount = PEZKUWICHAIN_ED * 10;
|
||||
|
||||
test_relay_is_trusted_teleporter!(
|
||||
Pezkuwichain, // Origin
|
||||
vec![CoretimePezkuwichain], // Destinations
|
||||
amount,
|
||||
limited_teleport_assets
|
||||
);
|
||||
|
||||
test_teyrchain_is_trusted_teleporter_for_relay!(
|
||||
CoretimePezkuwichain, // Origin
|
||||
Pezkuwichain, // Destination
|
||||
amount,
|
||||
limited_teleport_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_transfer_assets_from_and_to_relay() {
|
||||
let amount = PEZKUWICHAIN_ED * 10;
|
||||
|
||||
test_relay_is_trusted_teleporter!(
|
||||
Pezkuwichain, // Origin
|
||||
vec![CoretimePezkuwichain], // Destinations
|
||||
amount,
|
||||
transfer_assets
|
||||
);
|
||||
|
||||
test_teyrchain_is_trusted_teleporter_for_relay!(
|
||||
CoretimePezkuwichain, // Origin
|
||||
Pezkuwichain, // Destination
|
||||
amount,
|
||||
transfer_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_limited_teleport_assets_from_coretime_to_asset_hub() {
|
||||
let amount = ASSET_HUB_PEZKUWICHAIN_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
CoretimePezkuwichain, // Origin
|
||||
vec![AssetHubPezkuwichain], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
limited_teleport_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_transfer_assets_from_coretime_to_asset_hub() {
|
||||
let amount = ASSET_HUB_PEZKUWICHAIN_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
CoretimePezkuwichain, // Origin
|
||||
vec![AssetHubPezkuwichain], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
transfer_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_limited_teleport_assets_from_asset_hub_to_coretime() {
|
||||
let amount = CORETIME_PEZKUWICHAIN_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
AssetHubPezkuwichain, // Origin
|
||||
vec![CoretimePezkuwichain], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
limited_teleport_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_transfer_assets_from_asset_hub_to_coretime() {
|
||||
let amount = CORETIME_PEZKUWICHAIN_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
AssetHubPezkuwichain, // Origin
|
||||
vec![CoretimePezkuwichain], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
transfer_assets
|
||||
);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
[package]
|
||||
name = "coretime-zagros-integration-tests"
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
description = "Coretime Zagros runtime integration tests with xcm-emulator"
|
||||
publish = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
# Bizinikiwi
|
||||
pezframe-support = { workspace = true }
|
||||
pezpallet-broker = { workspace = true, default-features = true }
|
||||
pezpallet-message-queue = { workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
|
||||
# Pezkuwi
|
||||
pezkuwi-runtime-teyrchains = { workspace = true, default-features = true }
|
||||
xcm = { workspace = true }
|
||||
xcm-executor = { workspace = true }
|
||||
zagros-runtime-constants = { workspace = true, default-features = true }
|
||||
|
||||
# Pezcumulus
|
||||
pezcumulus-pezpallet-teyrchain-system = { workspace = true, default-features = true }
|
||||
emulated-integration-tests-common = { workspace = true }
|
||||
zagros-system-emulated-network = { workspace = true }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
"pezcumulus-pezpallet-teyrchain-system/runtime-benchmarks",
|
||||
"emulated-integration-tests-common/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezpallet-broker/runtime-benchmarks",
|
||||
"pezpallet-message-queue/runtime-benchmarks",
|
||||
"pezkuwi-runtime-teyrchains/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"xcm-executor/runtime-benchmarks",
|
||||
"xcm/runtime-benchmarks",
|
||||
"zagros-runtime-constants/runtime-benchmarks",
|
||||
"zagros-system-emulated-network/runtime-benchmarks",
|
||||
]
|
||||
+53
@@ -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.
|
||||
|
||||
#[cfg(test)]
|
||||
mod imports {
|
||||
|
||||
// Bizinikiwi
|
||||
pub(crate) use pezframe_support::assert_ok;
|
||||
|
||||
// Pezkuwi
|
||||
pub(crate) use xcm::{latest::ZAGROS_GENESIS_HASH, prelude::*};
|
||||
|
||||
// Pezcumulus
|
||||
pub(crate) use emulated_integration_tests_common::xcm_emulator::{
|
||||
assert_expected_events, Chain, TestExt, Teyrchain,
|
||||
};
|
||||
pub(crate) use zagros_system_emulated_network::{
|
||||
asset_hub_zagros_emulated_chain::{
|
||||
genesis::ED as ASSET_HUB_ZAGROS_ED, AssetHubZagrosParaPallet as AssetHubZagrosPallet,
|
||||
},
|
||||
bridge_hub_zagros_emulated_chain::BridgeHubZagrosParaPallet as BridgeHubZagrosPallet,
|
||||
collectives_zagros_emulated_chain::CollectivesZagrosParaPallet as CollectivesZagrosPallet,
|
||||
coretime_zagros_emulated_chain::{
|
||||
self, coretime_zagros_runtime::ExistentialDeposit as CoretimeZagrosExistentialDeposit,
|
||||
genesis::ED as CORETIME_ZAGROS_ED, CoretimeZagrosParaPallet as CoretimeZagrosPallet,
|
||||
},
|
||||
penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPallet as PenpalBPallet},
|
||||
people_zagros_emulated_chain::PeopleZagrosParaPallet as PeopleZagrosPallet,
|
||||
zagros_emulated_chain::{genesis::ED as ZAGROS_ED, ZagrosRelayPallet as ZagrosPallet},
|
||||
AssetHubZagrosPara as AssetHubZagros, AssetHubZagrosParaReceiver as AssetHubZagrosReceiver,
|
||||
AssetHubZagrosParaSender as AssetHubZagrosSender, BridgeHubZagrosPara as BridgeHubZagros,
|
||||
CollectivesZagrosPara as CollectivesZagros, CoretimeZagrosPara as CoretimeZagros,
|
||||
CoretimeZagrosParaReceiver as CoretimeZagrosReceiver,
|
||||
CoretimeZagrosParaSender as CoretimeZagrosSender, PenpalBPara as PenpalB,
|
||||
PeopleZagrosPara as PeopleZagros, ZagrosRelay as Zagros,
|
||||
ZagrosRelayReceiver as ZagrosReceiver, ZagrosRelaySender as ZagrosSender,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
// 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.
|
||||
|
||||
//! Tests related to XCM aliasing.
|
||||
|
||||
use crate::imports::*;
|
||||
use coretime_zagros_emulated_chain::coretime_zagros_runtime::xcm_config::XcmConfig;
|
||||
use emulated_integration_tests_common::{macros::AccountId, test_cross_chain_alias};
|
||||
use pezframe_support::traits::ContainsPair;
|
||||
use xcm::latest::Junctions::*;
|
||||
|
||||
const ALLOWED: bool = true;
|
||||
const DENIED: bool = false;
|
||||
|
||||
const TELEPORT_FEES: bool = true;
|
||||
const RESERVE_TRANSFER_FEES: bool = false;
|
||||
|
||||
#[test]
|
||||
fn account_on_sibling_syschain_aliases_into_same_local_account() {
|
||||
// origin and target are the same account on different chains
|
||||
let origin: AccountId = [1; 32].into();
|
||||
let target = origin.clone();
|
||||
let fees = ZAGROS_ED * 10;
|
||||
|
||||
PenpalB::mint_foreign_asset(
|
||||
<PenpalB as Chain>::RuntimeOrigin::signed(PenpalAssetOwner::get()),
|
||||
Location::parent(),
|
||||
origin.clone(),
|
||||
fees * 10,
|
||||
);
|
||||
|
||||
// Aliasing same account on different chains
|
||||
test_cross_chain_alias!(
|
||||
vec![
|
||||
// between AH and Coretime: allowed
|
||||
(AssetHubZagros, CoretimeZagros, TELEPORT_FEES, ALLOWED),
|
||||
// between BH and Coretime: allowed
|
||||
(BridgeHubZagros, CoretimeZagros, TELEPORT_FEES, ALLOWED),
|
||||
// between Collectives and Coretime: allowed
|
||||
(CollectivesZagros, CoretimeZagros, TELEPORT_FEES, ALLOWED),
|
||||
// between People and Coretime: allowed
|
||||
(PeopleZagros, CoretimeZagros, TELEPORT_FEES, ALLOWED),
|
||||
// between Penpal and Coretime: denied
|
||||
(PenpalB, CoretimeZagros, RESERVE_TRANSFER_FEES, DENIED)
|
||||
],
|
||||
origin,
|
||||
target,
|
||||
fees
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn account_on_sibling_syschain_cannot_alias_into_different_local_account() {
|
||||
// origin and target are different accounts on different chains
|
||||
let origin: AccountId = [1; 32].into();
|
||||
let target: AccountId = [2; 32].into();
|
||||
let fees = ZAGROS_ED * 10;
|
||||
|
||||
PenpalB::mint_foreign_asset(
|
||||
<PenpalB as Chain>::RuntimeOrigin::signed(PenpalAssetOwner::get()),
|
||||
Location::parent(),
|
||||
origin.clone(),
|
||||
fees * 10,
|
||||
);
|
||||
|
||||
// Aliasing different account on different chains
|
||||
test_cross_chain_alias!(
|
||||
vec![
|
||||
// between AH and Coretime: denied
|
||||
(AssetHubZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between BH and Coretime: denied
|
||||
(BridgeHubZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between Collectives and Coretime: denied
|
||||
(CollectivesZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between People and Coretime: denied
|
||||
(PeopleZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between Penpal and Coretime: denied
|
||||
(PenpalB, CoretimeZagros, RESERVE_TRANSFER_FEES, DENIED)
|
||||
],
|
||||
origin,
|
||||
target,
|
||||
fees
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aliasing_child_locations() {
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Allows aliasing descendant of origin.
|
||||
let origin = Location::new(1, X1([PalletInstance(8)].into()));
|
||||
let target = Location::new(1, X2([PalletInstance(8), GeneralIndex(9)].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([Teyrchain(8)].into()));
|
||||
let target = Location::new(
|
||||
1,
|
||||
X2([Teyrchain(8), AccountId32 { network: None, id: [1u8; 32] }].into()),
|
||||
);
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([Teyrchain(8)].into()));
|
||||
let target =
|
||||
Location::new(1, X3([Teyrchain(8), PalletInstance(8), GeneralIndex(9)].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
|
||||
// Does not allow if not descendant.
|
||||
let origin = Location::new(1, X1([PalletInstance(8)].into()));
|
||||
let target = Location::new(0, X2([PalletInstance(8), GeneralIndex(9)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([Teyrchain(8)].into()));
|
||||
let target = Location::new(
|
||||
0,
|
||||
X2([Teyrchain(8), AccountId32 { network: None, id: [1u8; 32] }].into()),
|
||||
);
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([Teyrchain(8)].into()));
|
||||
let target = Location::new(0, X1([AccountId32 { network: None, id: [1u8; 32] }].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([AccountId32 { network: None, id: [1u8; 32] }].into()));
|
||||
let target = Location::new(0, X1([AccountId32 { network: None, id: [1u8; 32] }].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn asset_hub_root_aliases_anything() {
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Allows AH root to alias anything.
|
||||
let origin = Location::new(1, X1([Teyrchain(1000)].into()));
|
||||
|
||||
let target = Location::new(1, X1([Teyrchain(2000)].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(1, X1([AccountId32 { network: None, id: [1u8; 32] }].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(
|
||||
1,
|
||||
X2([Teyrchain(8), AccountId32 { network: None, id: [1u8; 32] }].into()),
|
||||
);
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target =
|
||||
Location::new(1, X3([Teyrchain(42), PalletInstance(8), GeneralIndex(9)].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(2, X1([GlobalConsensus(Ethereum { chain_id: 1 })].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(2, X2([GlobalConsensus(Pezkuwi), Teyrchain(1000)].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(0, X2([PalletInstance(8), GeneralIndex(9)].into()));
|
||||
assert!(<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
|
||||
// Other AH locations cannot alias anything.
|
||||
let origin = Location::new(1, X2([Teyrchain(1000), GeneralIndex(9)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X2([Teyrchain(1000), PalletInstance(9)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(
|
||||
1,
|
||||
X2([Teyrchain(1000), AccountId32 { network: None, id: [1u8; 32] }].into()),
|
||||
);
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
|
||||
// Other root locations cannot alias anything.
|
||||
let origin = Location::new(1, Here);
|
||||
let target = Location::new(2, X1([GlobalConsensus(Ethereum { chain_id: 1 })].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(2, X2([GlobalConsensus(Pezkuwi), Teyrchain(1000)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let target = Location::new(0, X2([PalletInstance(8), GeneralIndex(9)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
|
||||
let origin = Location::new(0, Here);
|
||||
let target = Location::new(1, X1([Teyrchain(2000)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([Teyrchain(1001)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
let origin = Location::new(1, X1([Teyrchain(1002)].into()));
|
||||
assert!(!<XcmConfig as xcm_executor::Config>::Aliasers::contains(&origin, &target));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn authorized_cross_chain_aliases() {
|
||||
// origin and target are different accounts on different chains
|
||||
let origin: AccountId = [100; 32].into();
|
||||
let bad_origin: AccountId = [150; 32].into();
|
||||
let target: AccountId = [200; 32].into();
|
||||
let fees = ZAGROS_ED * 10;
|
||||
|
||||
let pal_admin = <PenpalB as Chain>::RuntimeOrigin::signed(PenpalAssetOwner::get());
|
||||
PenpalB::mint_foreign_asset(pal_admin.clone(), Location::parent(), origin.clone(), fees * 10);
|
||||
PenpalB::mint_foreign_asset(pal_admin, Location::parent(), bad_origin.clone(), fees * 10);
|
||||
CoretimeZagros::fund_accounts(vec![(target.clone(), fees * 10)]);
|
||||
|
||||
// let's authorize `origin` on Penpal to alias `target` on Coretime
|
||||
CoretimeZagros::execute_with(|| {
|
||||
let penpal_origin = Location::new(
|
||||
1,
|
||||
X2([
|
||||
Teyrchain(PenpalB::para_id().into()),
|
||||
AccountId32 {
|
||||
network: Some(ByGenesis(ZAGROS_GENESIS_HASH)),
|
||||
id: origin.clone().into(),
|
||||
},
|
||||
]
|
||||
.into()),
|
||||
);
|
||||
// `target` adds `penpal_origin` as authorized alias
|
||||
assert_ok!(<CoretimeZagros as CoretimeZagrosPallet>::PezkuwiXcm::add_authorized_alias(
|
||||
<CoretimeZagros as Chain>::RuntimeOrigin::signed(target.clone()),
|
||||
Box::new(penpal_origin.into()),
|
||||
None
|
||||
));
|
||||
});
|
||||
// Verify that unauthorized `bad_origin` cannot alias into `target`, from any chain.
|
||||
test_cross_chain_alias!(
|
||||
vec![
|
||||
// between AH and Coretime: denied
|
||||
(AssetHubZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between BH and Coretime: denied
|
||||
(BridgeHubZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between People and Coretime: denied
|
||||
(PeopleZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between Penpal and Coretime: denied
|
||||
(PenpalB, CoretimeZagros, RESERVE_TRANSFER_FEES, DENIED)
|
||||
],
|
||||
bad_origin,
|
||||
target,
|
||||
fees
|
||||
);
|
||||
// Verify that only authorized `penpal::origin` can alias into `target`, while `origin` on other
|
||||
// chains cannot.
|
||||
test_cross_chain_alias!(
|
||||
vec![
|
||||
// between AH and Coretime: denied
|
||||
(AssetHubZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between BH and Coretime: denied
|
||||
(BridgeHubZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between People and Coretime: denied
|
||||
(PeopleZagros, CoretimeZagros, TELEPORT_FEES, DENIED),
|
||||
// between Penpal and Coretime: allowed
|
||||
(PenpalB, CoretimeZagros, RESERVE_TRANSFER_FEES, ALLOWED)
|
||||
],
|
||||
origin,
|
||||
target,
|
||||
fees
|
||||
);
|
||||
// remove authorization for `origin` on Penpal to alias `target` on Coretime
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// `target` removes all authorized aliases
|
||||
assert_ok!(
|
||||
<CoretimeZagros as CoretimeZagrosPallet>::PezkuwiXcm::remove_all_authorized_aliases(
|
||||
<CoretimeZagros as Chain>::RuntimeOrigin::signed(target.clone())
|
||||
)
|
||||
);
|
||||
});
|
||||
// Verify `penpal::origin` can no longer alias into `target` on Coretime.
|
||||
test_cross_chain_alias!(
|
||||
vec![(PenpalB, CoretimeZagros, RESERVE_TRANSFER_FEES, DENIED)],
|
||||
origin,
|
||||
target,
|
||||
fees
|
||||
);
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// 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.
|
||||
|
||||
//! Tests related to claiming assets trapped during XCM execution.
|
||||
|
||||
use crate::imports::*;
|
||||
|
||||
use emulated_integration_tests_common::test_chain_can_claim_assets;
|
||||
|
||||
#[test]
|
||||
fn assets_can_be_claimed() {
|
||||
let amount = CoretimeZagrosExistentialDeposit::get();
|
||||
let assets: Assets = (Parent, amount).into();
|
||||
|
||||
test_chain_can_claim_assets!(
|
||||
CoretimeZagros,
|
||||
RuntimeCall,
|
||||
NetworkId::ByGenesis(ZAGROS_GENESIS_HASH),
|
||||
assets,
|
||||
amount
|
||||
);
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
// 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.
|
||||
|
||||
use crate::imports::*;
|
||||
use pezframe_support::traits::OnInitialize;
|
||||
use pezpallet_broker::{ConfigRecord, Configuration, CoreAssignment, CoreMask, ScheduleItem};
|
||||
use pezsp_runtime::Perbill;
|
||||
use zagros_runtime_constants::system_teyrchain::coretime::TIMESLICE_PERIOD;
|
||||
use zagros_system_emulated_network::zagros_emulated_chain::zagros_runtime::Dmp;
|
||||
|
||||
#[test]
|
||||
fn transact_hardcoded_weights_are_sane() {
|
||||
// There are three transacts with hardcoded weights sent from the Coretime Chain to the Relay
|
||||
// Chain across the CoretimeInterface which are triggered at various points in the sales cycle.
|
||||
// - Request core count - triggered directly by `start_sales` or `request_core_count`
|
||||
// extrinsics.
|
||||
// - Request revenue info - triggered when each timeslice is committed.
|
||||
// - Assign core - triggered when an entry is encountered in the workplan for the next
|
||||
// timeslice.
|
||||
|
||||
// RuntimeEvent aliases to avoid warning from usage of qualified paths in assertions due to
|
||||
// <https://github.com/rust-lang/rust/issues/86935>
|
||||
type CoretimeEvent = <CoretimeZagros as Chain>::RuntimeEvent;
|
||||
type RelayEvent = <Zagros as Chain>::RuntimeEvent;
|
||||
|
||||
Zagros::execute_with(|| {
|
||||
Dmp::make_teyrchain_reachable(CoretimeZagros::para_id());
|
||||
});
|
||||
|
||||
// Reserve a workload, configure broker and start sales.
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround as we need `on_initialize` to tick things
|
||||
// along and have no concept of time passing otherwise.
|
||||
<CoretimeZagros as CoretimeZagrosPallet>::Broker::on_initialize(
|
||||
<CoretimeZagros as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
let coretime_root_origin = <CoretimeZagros as Chain>::RuntimeOrigin::root();
|
||||
|
||||
// Create and populate schedule with the worst case assignment on this core.
|
||||
let mut schedule = Vec::new();
|
||||
for i in 0..80 {
|
||||
schedule.push(ScheduleItem {
|
||||
mask: CoreMask::void().set(i),
|
||||
assignment: CoreAssignment::Task(2000 + i),
|
||||
})
|
||||
}
|
||||
|
||||
assert_ok!(<CoretimeZagros as CoretimeZagrosPallet>::Broker::reserve(
|
||||
coretime_root_origin.clone(),
|
||||
schedule.try_into().expect("Vector is within bounds."),
|
||||
));
|
||||
|
||||
// Configure broker and start sales.
|
||||
let config = ConfigRecord {
|
||||
advance_notice: 1,
|
||||
interlude_length: 1,
|
||||
leadin_length: 2,
|
||||
region_length: 1,
|
||||
ideal_bulk_proportion: Perbill::from_percent(40),
|
||||
limit_cores_offered: None,
|
||||
renewal_bump: Perbill::from_percent(2),
|
||||
contribution_timeout: 1,
|
||||
};
|
||||
assert_ok!(<CoretimeZagros as CoretimeZagrosPallet>::Broker::configure(
|
||||
coretime_root_origin.clone(),
|
||||
config
|
||||
));
|
||||
assert_ok!(<CoretimeZagros as CoretimeZagrosPallet>::Broker::start_sales(
|
||||
coretime_root_origin,
|
||||
100,
|
||||
0
|
||||
));
|
||||
assert_eq!(
|
||||
pezpallet_broker::Status::<<CoretimeZagros as Chain>::Runtime>::get()
|
||||
.unwrap()
|
||||
.core_count,
|
||||
1
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimeZagros,
|
||||
vec![
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::ReservationMade { .. }
|
||||
) => {},
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::CoreCountRequested { core_count: 1 }
|
||||
) => {},
|
||||
CoretimeEvent::TeyrchainSystem(
|
||||
cumulus_pallet_teyrchain_system::Event::UpwardMessageSent { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check that the request_core_count message was processed successfully. This will fail if the
|
||||
// weights are misconfigured.
|
||||
Zagros::execute_with(|| {
|
||||
Zagros::assert_ump_queue_processed(true, Some(CoretimeZagros::para_id()), None);
|
||||
|
||||
assert_expected_events!(
|
||||
Zagros,
|
||||
vec![
|
||||
RelayEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Keep track of the relay chain block number so we can fast forward while still checking the
|
||||
// right block.
|
||||
let mut block_number_cursor = Zagros::ext_wrapper(<Zagros as Chain>::System::block_number);
|
||||
|
||||
let config = CoretimeZagros::ext_wrapper(|| {
|
||||
Configuration::<<CoretimeZagros as Chain>::Runtime>::get()
|
||||
.expect("Pallet was configured earlier.")
|
||||
});
|
||||
|
||||
// Now run up to the block before the sale is rotated.
|
||||
while block_number_cursor < TIMESLICE_PERIOD - config.advance_notice - 1 {
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimeZagros as CoretimeZagrosPallet>::Broker::on_initialize(
|
||||
<CoretimeZagros as Chain>::System::block_number(),
|
||||
);
|
||||
});
|
||||
|
||||
Zagros::ext_wrapper(|| {
|
||||
block_number_cursor = <Zagros as Chain>::System::block_number();
|
||||
});
|
||||
}
|
||||
|
||||
// In this block we trigger assign core.
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimeZagros as CoretimeZagrosPallet>::Broker::on_initialize(
|
||||
<CoretimeZagros as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimeZagros,
|
||||
vec![
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::SaleInitialized { .. }
|
||||
) => {},
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::CoreAssigned { .. }
|
||||
) => {},
|
||||
CoretimeEvent::TeyrchainSystem(
|
||||
cumulus_pallet_teyrchain_system::Event::UpwardMessageSent { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// In this block we trigger request revenue.
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimeZagros as CoretimeZagrosPallet>::Broker::on_initialize(
|
||||
<CoretimeZagros as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimeZagros,
|
||||
vec![
|
||||
CoretimeEvent::TeyrchainSystem(
|
||||
cumulus_pallet_teyrchain_system::Event::UpwardMessageSent { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Check that the assign_core and request_revenue_info_at messages were processed successfully.
|
||||
// This will fail if the weights are misconfigured.
|
||||
Zagros::execute_with(|| {
|
||||
Zagros::assert_ump_queue_processed(true, Some(CoretimeZagros::para_id()), None);
|
||||
|
||||
assert_expected_events!(
|
||||
Zagros,
|
||||
vec![
|
||||
RelayEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
RelayEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
RelayEvent::Coretime(
|
||||
pezkuwi_runtime_teyrchains::coretime::Event::CoreAssigned { .. }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Here we receive and process the notify_revenue XCM with zero revenue.
|
||||
CoretimeZagros::execute_with(|| {
|
||||
// Hooks don't run in emulated tests - workaround.
|
||||
<CoretimeZagros as CoretimeZagrosPallet>::Broker::on_initialize(
|
||||
<CoretimeZagros as Chain>::System::block_number(),
|
||||
);
|
||||
|
||||
assert_expected_events!(
|
||||
CoretimeZagros,
|
||||
vec![
|
||||
CoretimeEvent::MessageQueue(
|
||||
pezpallet_message_queue::Event::Processed { success: true, .. }
|
||||
) => {},
|
||||
// Zero revenue in first timeslice so history is immediately dropped.
|
||||
CoretimeEvent::Broker(
|
||||
pezpallet_broker::Event::HistoryDropped { when: 0, revenue: 0 }
|
||||
) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
mod aliases;
|
||||
mod claim_assets;
|
||||
mod coretime_interface;
|
||||
mod teleport;
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
// 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.
|
||||
|
||||
use crate::imports::*;
|
||||
use emulated_integration_tests_common::{
|
||||
test_relay_is_trusted_teleporter, test_teyrchain_is_trusted_teleporter,
|
||||
test_teyrchain_is_trusted_teleporter_for_relay,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn teleport_via_limited_teleport_assets_from_and_to_relay() {
|
||||
let amount = ZAGROS_ED * 10;
|
||||
|
||||
test_relay_is_trusted_teleporter!(
|
||||
Zagros, // Origin
|
||||
vec![CoretimeZagros], // Destinations
|
||||
amount,
|
||||
limited_teleport_assets
|
||||
);
|
||||
|
||||
test_teyrchain_is_trusted_teleporter_for_relay!(
|
||||
CoretimeZagros, // Origin
|
||||
Zagros, // Destination
|
||||
amount,
|
||||
limited_teleport_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_transfer_assets_from_and_to_relay() {
|
||||
let amount = ZAGROS_ED * 10;
|
||||
|
||||
test_relay_is_trusted_teleporter!(
|
||||
Zagros, // Origin
|
||||
vec![CoretimeZagros], // Destinations
|
||||
amount,
|
||||
transfer_assets
|
||||
);
|
||||
|
||||
test_teyrchain_is_trusted_teleporter_for_relay!(
|
||||
CoretimeZagros, // Origin
|
||||
Zagros, // Destination
|
||||
amount,
|
||||
transfer_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_limited_teleport_assets_from_coretime_to_asset_hub() {
|
||||
let amount = ASSET_HUB_ZAGROS_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
CoretimeZagros, // Origin
|
||||
vec![AssetHubZagros], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
limited_teleport_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_transfer_assets_from_coretime_to_asset_hub() {
|
||||
let amount = ASSET_HUB_ZAGROS_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
CoretimeZagros, // Origin
|
||||
vec![AssetHubZagros], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
transfer_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_limited_teleport_assets_from_asset_hub_to_coretime() {
|
||||
let amount = CORETIME_ZAGROS_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
AssetHubZagros, // Origin
|
||||
vec![CoretimeZagros], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
limited_teleport_assets
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn teleport_via_transfer_assets_from_asset_hub_to_coretime() {
|
||||
let amount = CORETIME_ZAGROS_ED * 100;
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
let fee_asset_id: AssetId = Parent.into();
|
||||
test_teyrchain_is_trusted_teleporter!(
|
||||
AssetHubZagros, // Origin
|
||||
vec![CoretimeZagros], // Destinations
|
||||
(native_asset, amount),
|
||||
fee_asset_id,
|
||||
transfer_assets
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user