[xcm-emulator] Redo Parachain init (#1356)

* 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>
This commit is contained in:
Ignacio Palacios
2023-09-04 12:30:25 +02:00
committed by GitHub
parent a30092ab42
commit 2c35bc3d27
7 changed files with 142 additions and 138 deletions
@@ -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 { .. }) => {},
]
);
});
}