Companion for polkadot#7234 (XCM: Tools for uniquely referencing messages) (#2601)

* Fixes for new API

* Formatting

* Fixes

* Fixes

* Further fixes

* XCMP dispatch events mention message ID

* XCMP event includes ID

* Add DMP message ID functionality

* Integrate into test parachains

* Remove WithUniqueTopic usage

* Use new primitive

* Formatting

* undiener

* Revert lock

* Fixes

* Fixes

* Fixes

* Fixes

* Formatting

* message_hash becomes message_id

* Rename

* Another Rename

* Fixes

* Fix

* Bump

* Fixes

* Grumble.
This commit is contained in:
Gavin Wood
2023-05-25 16:52:38 +01:00
committed by GitHub
parent febea66397
commit ec21c0a24d
23 changed files with 431 additions and 569 deletions
@@ -8,6 +8,7 @@ description = "Utils for BridgeHub testing"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
log = { version = "0.4.17", default-features = false }
assert_matches = "1.4.0"
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
@@ -16,6 +16,7 @@
//! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities.
use assert_matches::assert_matches;
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch, SourceHeaderChain},
LaneId, MessageKey, OutboundLaneData, Weight,
@@ -462,7 +463,7 @@ pub fn relayed_incoming_message_works<Runtime, XcmConfig, HrmpChannelOpener, GPI
let relayer_id_on_source: AccountId32 = relayer_at_source.public().into();
let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42];
let expected_dispatch = xcm::VersionedXcm::<()>::V3(xcm.clone().into());
let expected_dispatch = xcm::latest::Xcm::<()>(xcm.clone());
// generate bridged relay chain finality, parachain heads and message proofs,
// to be submitted by relayer to this chain.
let (
@@ -559,6 +560,9 @@ pub fn relayed_incoming_message_works<Runtime, XcmConfig, HrmpChannelOpener, GPI
sibling_parachain_id.into(),
)
.unwrap();
let mut dispatched = xcm::latest::Xcm::<()>::try_from(dispatched).unwrap();
// We use `WithUniqueTopic`, so expect a trailing `SetTopic`.
assert_matches!(dispatched.0.pop(), Some(SetTopic(..)));
assert_eq!(dispatched, expected_dispatch);
})
}
@@ -667,8 +671,8 @@ pub fn complex_relay_extrinsic_works<Runtime, XcmConfig, HrmpChannelOpener, GPI,
let para_header_number = 5;
let relay_header_number = 1;
let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42];
let expected_dispatch = xcm::VersionedXcm::<()>::V3(xcm.clone().into());
let xcm = vec![xcm::latest::Instruction::<()>::ClearOrigin; 42];
let expected_dispatch = xcm::latest::Xcm::<()>(xcm.clone());
// generate bridged relay chain finality, parachain heads and message proofs,
// to be submitted by relayer to this chain.
let (
@@ -776,6 +780,9 @@ pub fn complex_relay_extrinsic_works<Runtime, XcmConfig, HrmpChannelOpener, GPI,
sibling_parachain_id.into(),
)
.unwrap();
let mut dispatched = xcm::latest::Xcm::<()>::try_from(dispatched).unwrap();
// We use `WithUniqueTopic`, so expect a trailing `SetTopic`.
assert_matches!(dispatched.0.pop(), Some(SetTopic(..)));
assert_eq!(dispatched, expected_dispatch);
})
}