Skip to content

Commit

Permalink
[xcm-emulator] Redo Parachain init (#1356)
Browse files Browse the repository at this point in the history
* bring back proper init

* refactor block cycle

* ".git/.scripts/commands/fmt/fmt.sh"

* Update cumulus/xcm/xcm-emulator/src/lib.rs

Co-authored-by: Squirrel <gilescope@gmail.com>

---------

Co-authored-by: command-bot <>
Co-authored-by: Giles Cope <gilescope@gmail.com>
  • Loading branch information
2 people authored and Ank4n committed Sep 8, 2023
1 parent d3ba197 commit b14a908
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
PenpalKusamaA::assert_xcm_pallet_sent();
});

PenpalKusamaA::execute_with(|| {});

AssetHubKusama::execute_with(|| {
type RuntimeEvent = <AssetHubKusama as Chain>::RuntimeEvent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
PenpalPolkadotA::assert_xcm_pallet_sent();
});

PenpalPolkadotA::execute_with(|| {});

AssetHubPolkadot::execute_with(|| {
type RuntimeEvent = <AssetHubPolkadot as Chain>::RuntimeEvent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ fn limited_teleport_native_assets_from_relay_to_system_para_works() {
/// Limited Teleport of native asset from System Parachain to Relay Chain
/// should work when there is enough balance in Relay Chain's `CheckAccount`
#[test]
#[cfg(feature = "FIXME-IGNORED")] // <https://github.com/paritytech/cumulus/issues/3027>
fn limited_teleport_native_assets_back_from_system_para_to_relay_works() {
// Dependency - Relay Chain's `CheckAccount` should have enough balance
limited_teleport_native_assets_from_relay_to_system_para_works();
Expand Down Expand Up @@ -226,7 +225,6 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() {
/// Limited Teleport of native asset from System Parachain to Relay Chain
/// should't work when there is not enough balance in Relay Chain's `CheckAccount`
#[test]
#[cfg(feature = "FIXME-IGNORED")] // <https://github.com/paritytech/cumulus/issues/3027>
fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
// Init values for Relay Chain
let amount_to_send: Balance = ASSET_HUB_POLKADOT_ED * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
PenpalWestendA::assert_xcm_pallet_sent();
});

PenpalWestendA::execute_with(|| {});

AssetHubWestend::execute_with(|| {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,85 +14,86 @@
// 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]
#[ignore]
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;
// 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 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,
// },
// ]));
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),
// ));
//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;
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!(
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::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,
// }) => {},
// ]
// );
// });
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 Chain>::RuntimeEvent;
// 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!(
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::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { .. }) => {},
// ]
// );
// });
assert_expected_events!(
AssetHubWococo,
vec![
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Fail { .. }) => {},
]
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ fn pay_salary() {
);
});

Collectives::execute_with(|| {});

AssetHubPolkadot::execute_with(|| {
type RuntimeEvent = <AssetHubPolkadot as Chain>::RuntimeEvent;

assert_expected_events!(
AssetHubPolkadot,
vec![
Expand Down
Loading

0 comments on commit b14a908

Please sign in to comment.