mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Added xcmp_queue_send_xcm_works test (#1422)
This PR adds test case for successful `send_xcm` for `XcmpQueue` according to the opened HRMP channel to the sibling parachain.
This commit is contained in:
@@ -1400,12 +1400,12 @@ impl<T: Config> Pallet<T> {
|
|||||||
CustomValidationHeadData::<T>::put(head_data);
|
CustomValidationHeadData::<T>::put(head_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open HRMP channel for using it in benchmarks.
|
/// Open HRMP channel for using it in benchmarks or tests.
|
||||||
///
|
///
|
||||||
/// The caller assumes that the pallet will accept regular outbound message to the sibling
|
/// The caller assumes that the pallet will accept regular outbound message to the sibling
|
||||||
/// `target_parachain` after this call. No other assumptions are made.
|
/// `target_parachain` after this call. No other assumptions are made.
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(any(feature = "runtime-benchmarks", feature = "std"))]
|
||||||
pub fn open_outbound_hrmp_channel_for_benchmarks(target_parachain: ParaId) {
|
pub fn open_outbound_hrmp_channel_for_benchmarks_or_tests(target_parachain: ParaId) {
|
||||||
RelevantMessagingState::<T>::put(MessagingStateSnapshot {
|
RelevantMessagingState::<T>::put(MessagingStateSnapshot {
|
||||||
dmq_mqc_head: Default::default(),
|
dmq_mqc_head: Default::default(),
|
||||||
relay_dispatch_queue_remaining_capacity: Default::default(),
|
relay_dispatch_queue_remaining_capacity: Default::default(),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pallet-balances = { path = "../../../substrate/frame/balances" }
|
|||||||
xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/xcm-builder" }
|
xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/xcm-builder" }
|
||||||
|
|
||||||
# Cumulus
|
# Cumulus
|
||||||
cumulus-pallet-parachain-system = { path = "../parachain-system" }
|
cumulus-pallet-parachain-system = { path = "../parachain-system", features = ["parameterized-consensus-hook"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std" ]
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use cumulus_primitives_core::XcmpMessageHandler;
|
use cumulus_primitives_core::{ParaId, XcmpMessageHandler};
|
||||||
use frame_support::{assert_noop, assert_ok};
|
use frame_support::{assert_noop, assert_ok};
|
||||||
use mock::{new_test_ext, RuntimeCall, RuntimeOrigin, Test, XcmpQueue};
|
use mock::{new_test_ext, ParachainSystem, RuntimeCall, RuntimeOrigin, Test, XcmpQueue};
|
||||||
use sp_runtime::traits::BadOrigin;
|
use sp_runtime::traits::BadOrigin;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -341,3 +341,32 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn xcmp_queue_send_xcm_works() {
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
let sibling_para_id = ParaId::from(12345);
|
||||||
|
let dest = (Parent, X1(Parachain(sibling_para_id.into()))).into();
|
||||||
|
let msg = Xcm(vec![ClearOrigin]);
|
||||||
|
|
||||||
|
// try to send without opened HRMP channel to the sibling_para_id
|
||||||
|
assert_eq!(
|
||||||
|
send_xcm::<XcmpQueue>(dest, msg.clone()),
|
||||||
|
Err(SendError::Transport("NoChannel")),
|
||||||
|
);
|
||||||
|
|
||||||
|
// open HRMP channel to the sibling_para_id
|
||||||
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(sibling_para_id);
|
||||||
|
|
||||||
|
// check empty outbound queue
|
||||||
|
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
|
||||||
|
|
||||||
|
// now send works
|
||||||
|
assert_ok!(send_xcm::<XcmpQueue>(dest, msg));
|
||||||
|
|
||||||
|
// check outbound queue contains message/page for sibling_para_id
|
||||||
|
assert!(XcmpQueue::take_outbound_messages(usize::MAX)
|
||||||
|
.iter()
|
||||||
|
.any(|(para_id, _)| para_id == &sibling_para_id));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1070,7 +1070,7 @@ impl_runtime_apis! {
|
|||||||
) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) {
|
) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) {
|
||||||
use cumulus_primitives_core::XcmpMessageSource;
|
use cumulus_primitives_core::XcmpMessageSource;
|
||||||
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
|
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks(42.into());
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
|
||||||
prepare_message_proof_from_parachain::<
|
prepare_message_proof_from_parachain::<
|
||||||
Runtime,
|
Runtime,
|
||||||
BridgeGrandpaWococoInstance,
|
BridgeGrandpaWococoInstance,
|
||||||
@@ -1113,7 +1113,7 @@ impl_runtime_apis! {
|
|||||||
) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) {
|
) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) {
|
||||||
use cumulus_primitives_core::XcmpMessageSource;
|
use cumulus_primitives_core::XcmpMessageSource;
|
||||||
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
|
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks(42.into());
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
|
||||||
prepare_message_proof_from_parachain::<
|
prepare_message_proof_from_parachain::<
|
||||||
Runtime,
|
Runtime,
|
||||||
BridgeGrandpaRococoInstance,
|
BridgeGrandpaRococoInstance,
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ pub mod benchmarks {
|
|||||||
impl<I: Get<u32>> EnsureSuccessful for OpenHrmpChannel<I> {
|
impl<I: Get<u32>> EnsureSuccessful for OpenHrmpChannel<I> {
|
||||||
fn ensure_successful() {
|
fn ensure_successful() {
|
||||||
if let ChannelStatus::Closed = ParachainSystem::get_channel_status(I::get().into()) {
|
if let ChannelStatus::Closed = ParachainSystem::get_channel_status(I::get().into()) {
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks(I::get().into())
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(I::get().into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user