-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[testnets][xcm-emulator] add bridge-hub-westend and hook it up to emu…
…lator (#2204) `bridge-hub-westend-runtime` was added to cumulus/parachains, but wasn't hooked up to xcm-emulator to run tests against it. This commit addresses that ^. Signed-off-by: Adrian Catangiu <[email protected]>
- Loading branch information
Showing
11 changed files
with
345 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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-westend-integration-tests" | ||
version = "1.0.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license = "Apache-2.0" | ||
description = "Bridge Hub Westend 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-westend-runtime = { path = "../../../../../parachains/runtimes/bridge-hubs/bridge-hub-westend", 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_westend::ED as BRIDGE_HUB_WESTEND_ED, westend::ED as WESTEND_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, AssetHubWestend, AssetHubWestendReceiver, BridgeHubRococo, BridgeHubWestend, | ||
BridgeHubWestendPallet, BridgeHubWestendSender, PenpalWestendA, Westend, WestendPallet, | ||
}; | ||
pub use parachains_common::{AccountId, Balance}; | ||
pub use xcm::{ | ||
prelude::{AccountId32 as AccountId32Junction, *}, | ||
v3::{ | ||
Error, | ||
NetworkId::{Rococo as RococoId, Westend as WestendId}, | ||
}, | ||
}; | ||
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<Westend, AssetHubWestend>; | ||
pub type SystemParaToRelayTest = Test<AssetHubWestend, Westend>; | ||
pub type SystemParaToParaTest = Test<AssetHubWestend, PenpalWestendA>; | ||
|
||
/// Returns a `TestArgs` instance to de used for the Relay Chain accross integraton tests | ||
pub fn relay_test_args(amount: Balance) -> TestArgs { | ||
TestArgs { | ||
dest: Westend::child_location_of(AssetHubWestend::para_id()), | ||
beneficiary: AccountId32Junction { | ||
network: None, | ||
id: AssetHubWestendReceiver::get().into(), | ||
} | ||
.into(), | ||
amount, | ||
assets: (Here, amount).into(), | ||
asset_id: None, | ||
fee_asset_item: 0, | ||
weight_limit: WeightLimit::Unlimited, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests; |
74 changes: 74 additions & 0 deletions
74
...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,74 @@ | ||
// 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 = <Westend as Chain>::RuntimeOrigin::root(); | ||
let destination = Westend::child_location_of(BridgeHubWestend::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: RococoId, | ||
destination: X1(Parachain(AssetHubRococo::para_id().into())), | ||
xcm: remote_xcm, | ||
}, | ||
])); | ||
|
||
// Westend Global Consensus | ||
// Send XCM message from Relay Chain to Bridge Hub source Parachain | ||
Westend::execute_with(|| { | ||
assert_ok!(<Westend as WestendPallet>::XcmPallet::send( | ||
sudo_origin, | ||
bx!(destination), | ||
bx!(xcm), | ||
)); | ||
|
||
type RuntimeEvent = <Westend as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
Westend, | ||
vec![ | ||
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, | ||
] | ||
); | ||
}); | ||
// Receive XCM message in Bridge Hub source Parachain | ||
BridgeHubWestend::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent; | ||
|
||
assert_expected_events!( | ||
BridgeHubWestend, | ||
vec![ | ||
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { | ||
success: true, | ||
.. | ||
}) => {}, | ||
RuntimeEvent::BridgeRococoMessages(pallet_bridge_messages::Event::MessageAccepted { | ||
lane_id: LaneId([0, 0, 0, 2]), | ||
nonce: 1, | ||
}) => {}, | ||
] | ||
); | ||
}); | ||
} |
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_westend_runtime::xcm_config::XcmConfig; | ||
|
||
#[test] | ||
fn teleport_to_other_system_parachains_works() { | ||
let amount = BRIDGE_HUB_WESTEND_ED * 100; | ||
let native_asset: MultiAssets = (Parent, amount).into(); | ||
|
||
test_parachain_is_trusted_teleporter!( | ||
BridgeHubWestend, // Origin | ||
XcmConfig, // XCM configuration | ||
vec![AssetHubWestend], // Destinations | ||
(native_asset, amount) | ||
); | ||
} |
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
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
Oops, something went wrong.