-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xcm-emulator: add bridge-hub-westend as copy of bridge-hub-rococo
- Loading branch information
Showing
5 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-westend/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[package] | ||
name = "bridge-hub-rococo-integration-tests" | ||
version = "1.0.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license = "Apache-2.0" | ||
description = "Bridge Hub Rococo runtime integration tests with xcm-emulator" | ||
publish = false | ||
|
||
[dependencies] | ||
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } | ||
|
||
# Substrate | ||
frame-support = { path = "../../../../../../substrate/frame/support", default-features = false} | ||
frame-system = { path = "../../../../../../substrate/frame/system", default-features = false} | ||
sp-core = { path = "../../../../../../substrate/primitives/core", default-features = false} | ||
sp-weights = { path = "../../../../../../substrate/primitives/weights", default-features = false} | ||
pallet-balances = { path = "../../../../../../substrate/frame/balances", default-features = false} | ||
pallet-assets = { path = "../../../../../../substrate/frame/assets", default-features = false} | ||
pallet-message-queue = { path = "../../../../../../substrate/frame/message-queue", default-features = false } | ||
|
||
# Polkadot | ||
polkadot-core-primitives = { path = "../../../../../../polkadot/core-primitives", default-features = false} | ||
polkadot-parachain-primitives = { path = "../../../../../../polkadot/parachain", default-features = false} | ||
polkadot-runtime-parachains = { path = "../../../../../../polkadot/runtime/parachains" } | ||
xcm = { package = "staging-xcm", path = "../../../../../../polkadot/xcm", default-features = false} | ||
pallet-xcm = { path = "../../../../../../polkadot/xcm/pallet-xcm", default-features = false} | ||
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../../polkadot/xcm/xcm-executor", default-features = false} | ||
|
||
# Cumulus | ||
asset-test-utils = { path = "../../../../../parachains/runtimes/assets/test-utils", default-features = false } | ||
parachains-common = { path = "../../../../common" } | ||
cumulus-pallet-xcmp-queue = { path = "../../../../../pallets/xcmp-queue", default-features = false} | ||
cumulus-pallet-dmp-queue = { path = "../../../../../pallets/dmp-queue", default-features = false} | ||
pallet-bridge-messages = { path = "../../../../../../bridges/modules/messages", default-features = false} | ||
bp-messages = { path = "../../../../../../bridges/primitives/messages", default-features = false} | ||
bridge-hub-rococo-runtime = { path = "../../../../../parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false } | ||
|
||
# Local | ||
xcm-emulator = { path = "../../../../../xcm/xcm-emulator", default-features = false} | ||
integration-tests-common = { path = "../../common", default-features = false} |
67 changes: 67 additions & 0 deletions
67
cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-westend/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// 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 bp_messages::LaneId; | ||
pub use frame_support::assert_ok; | ||
pub use integration_tests_common::{ | ||
constants::{ | ||
bridge_hub_rococo::ED as BRIDGE_HUB_ROCOCO_ED, rococo::ED as ROCOCO_ED, | ||
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, | ||
}, | ||
test_parachain_is_trusted_teleporter, | ||
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution}, | ||
AssetHubRococo, AssetHubRococoReceiver, AssetHubWococo, BridgeHubRococo, BridgeHubRococoPallet, | ||
BridgeHubRococoSender, BridgeHubWococo, PenpalRococoA, Rococo, RococoPallet, | ||
}; | ||
pub use parachains_common::{AccountId, Balance}; | ||
pub use xcm::{ | ||
prelude::{AccountId32 as AccountId32Junction, *}, | ||
v3::{ | ||
Error, | ||
NetworkId::{Rococo as RococoId, Wococo as WococoId}, | ||
}, | ||
}; | ||
pub use xcm_emulator::{ | ||
assert_expected_events, bx, helpers::weight_within_threshold, Chain, Parachain as Para, | ||
RelayChain as Relay, Test, TestArgs, TestContext, TestExt, | ||
}; | ||
|
||
pub const ASSET_ID: u32 = 1; | ||
pub const ASSET_MIN_BALANCE: u128 = 1000; | ||
pub const ASSETS_PALLET_ID: u8 = 50; | ||
|
||
pub type RelayToSystemParaTest = Test<Rococo, AssetHubRococo>; | ||
pub type SystemParaToRelayTest = Test<AssetHubRococo, Rococo>; | ||
pub type SystemParaToParaTest = Test<AssetHubRococo, PenpalRococoA>; | ||
|
||
/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests | ||
pub fn relay_test_args(amount: Balance) -> TestArgs { | ||
TestArgs { | ||
dest: Rococo::child_location_of(AssetHubRococo::para_id()), | ||
beneficiary: AccountId32Junction { | ||
network: None, | ||
id: AssetHubRococoReceiver::get().into(), | ||
} | ||
.into(), | ||
amount, | ||
assets: (Here, amount).into(), | ||
asset_id: None, | ||
fee_asset_item: 0, | ||
weight_limit: WeightLimit::Unlimited, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests; |
100 changes: 100 additions & 0 deletions
100
...lus/parachains/integration-tests/emulated/bridges/bridge-hub-westend/src/tests/example.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// 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::*; | ||
|
||
#[test] | ||
fn example() { | ||
// Init tests variables | ||
// XcmPallet send arguments | ||
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root(); | ||
let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into(); | ||
let weight_limit = WeightLimit::Unlimited; | ||
let check_origin = None; | ||
|
||
let remote_xcm = Xcm(vec![ClearOrigin]); | ||
|
||
let xcm = VersionedXcm::from(Xcm(vec![ | ||
UnpaidExecution { weight_limit, check_origin }, | ||
ExportMessage { | ||
network: WococoId, | ||
destination: X1(Parachain(AssetHubWococo::para_id().into())), | ||
xcm: remote_xcm, | ||
}, | ||
])); | ||
|
||
//Rococo Global Consensus | ||
// Send XCM message from Relay Chain to Bridge Hub source Parachain | ||
Rococo::execute_with(|| { | ||
assert_ok!(<Rococo as RococoPallet>::XcmPallet::send( | ||
sudo_origin, | ||
bx!(destination), | ||
bx!(xcm), | ||
)); | ||
|
||
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
Rococo, | ||
vec![ | ||
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, | ||
] | ||
); | ||
}); | ||
// Receive XCM message in Bridge Hub source Parachain | ||
BridgeHubRococo::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
BridgeHubRococo, | ||
vec![ | ||
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { | ||
success: true, | ||
.. | ||
}) => {}, | ||
RuntimeEvent::BridgeWococoMessages(pallet_bridge_messages::Event::MessageAccepted { | ||
lane_id: LaneId([0, 0, 0, 1]), | ||
nonce: 1, | ||
}) => {}, | ||
] | ||
); | ||
}); | ||
|
||
// Wococo GLobal Consensus | ||
// Receive XCM message in Bridge Hub target Parachain | ||
BridgeHubWococo::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubWococo as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
BridgeHubWococo, | ||
vec![ | ||
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, | ||
] | ||
); | ||
}); | ||
// Receive embeded XCM message within `ExportMessage` in Parachain destination | ||
AssetHubWococo::execute_with(|| { | ||
type RuntimeEvent = <AssetHubWococo as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
AssetHubWococo, | ||
vec![ | ||
RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed { | ||
.. | ||
}) => {}, | ||
] | ||
); | ||
}); | ||
} |
17 changes: 17 additions & 0 deletions
17
cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-westend/src/tests/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 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 example; | ||
mod teleport; |
30 changes: 30 additions & 0 deletions
30
...us/parachains/integration-tests/emulated/bridges/bridge-hub-westend/src/tests/teleport.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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::*; | ||
use bridge_hub_rococo_runtime::xcm_config::XcmConfig; | ||
|
||
#[test] | ||
fn teleport_to_other_system_parachains_works() { | ||
let amount = BRIDGE_HUB_ROCOCO_ED * 100; | ||
let native_asset: MultiAssets = (Parent, amount).into(); | ||
|
||
test_parachain_is_trusted_teleporter!( | ||
BridgeHubRococo, // Origin | ||
XcmConfig, // XCM configuration | ||
vec![AssetHubRococo], // Destinations | ||
(native_asset, amount) | ||
); | ||
} |