mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Add Bridges to xcm-emulator (#2812)
* rename bridge hub + BridgeMessages type * bridge base * bridge string approach * add decl_test_bridges macro * outbound lanes on the way * get & dispatch mock bridge done * fix bridge errors + log::debug for messages * clean up * update source OutboundLaneData * rococo & wococo added * sender_receiver_accounts_parameter_types macro * sender_receiver_accounts_parameter_types macro 2 * fixed multi parachain + example on the way * working but router error * bridge working * refactor NetworkComponent * make it generic * working as generic * clean up * last bit * ".git/.scripts/commands/fmt/fmt.sh" * fix bridge hub handler name * ".git/.scripts/commands/fmt/fmt.sh" * add AssetConversion back for AssetHubWestend * Update xcm/xcm-emulator/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * add LaneId wrapper * update substrate * fix wrapper conversion * remove duplicate in workspace * Revert "update substrate" This reverts commit 92e8f201ae433aed3f70b998ebd4c23d9168d0ee. * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <> Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
[package]
|
||||
name = "bridge-hub-rococo-integration-tests"
|
||||
version = "1.0.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
description = "Bridge Hub Rococo runtime integration tests with xcm-emulator"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }
|
||||
|
||||
# Substrate
|
||||
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
|
||||
# Cumulus
|
||||
parachains-common = { path = "../../../../common" }
|
||||
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../pallets/xcmp-queue" }
|
||||
bridge-hub-rococo-runtime = { path = "../../../../runtimes/bridge-hubs/bridge-hub-rococo" }
|
||||
pallet-bridge-messages = { default-features = false, path = "../../../../../bridges/modules/messages" }
|
||||
bp-messages = { default-features = false, path = "../../../../../bridges/primitives/messages" }
|
||||
|
||||
# Local
|
||||
xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" }
|
||||
integration-tests-common = { default-features = false, path = "../../common" }
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub use bp_messages::LaneId;
|
||||
pub use codec::Encode;
|
||||
pub use frame_support::{assert_ok, pallet_prelude::Weight};
|
||||
pub use integration_tests_common::{
|
||||
constants::{
|
||||
accounts::{ALICE, BOB},
|
||||
rococo::{ED as ROCOCO_ED, ED as WOCOCO_ED},
|
||||
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
|
||||
},
|
||||
AccountId, AssetHubWococo, BridgeHubPolkadot, BridgeHubPolkadotPallet,
|
||||
BridgeHubPolkadotReceiver, BridgeHubPolkadotSender, BridgeHubRococo, BridgeHubRococoPallet,
|
||||
BridgeHubRococoReceiver, BridgeHubRococoSender, BridgeHubWococo, Collectives,
|
||||
CollectivesPallet, CollectivesReceiver, CollectivesSender, Kusama, KusamaPallet,
|
||||
PenpalPolkadot, PenpalPolkadotReceiver, PenpalPolkadotSender, Polkadot, PolkadotMockNet,
|
||||
PolkadotPallet, PolkadotReceiver, PolkadotSender, Rococo, RococoMockNet, RococoPallet,
|
||||
RococoReceiver, RococoSender,
|
||||
};
|
||||
// pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use xcm::{
|
||||
prelude::*,
|
||||
v3::{
|
||||
Error,
|
||||
NetworkId::{Rococo as RococoId, Wococo as WococoId},
|
||||
},
|
||||
};
|
||||
pub use xcm_emulator::{
|
||||
assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold,
|
||||
Parachain as Para, RelayChain as Relay, TestExt,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// Copyright Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::*;
|
||||
|
||||
#[test]
|
||||
fn example() {
|
||||
// Init tests variables
|
||||
// XcmPallet send arguments
|
||||
let sudo_origin = <Rococo as Relay>::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 Relay>::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 Para>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
BridgeHubRococo,
|
||||
vec![
|
||||
RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
|
||||
outcome: Outcome::Complete(_),
|
||||
..
|
||||
}) => {},
|
||||
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 Para>::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 Para>::RuntimeEvent;
|
||||
|
||||
assert_expected_events!(
|
||||
AssetHubWococo,
|
||||
vec![
|
||||
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { .. }) => {},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
mod example;
|
||||
Reference in New Issue
Block a user