Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cumulus/pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ try-runtime = [
]

parameterized-consensus-hook = []
test-helpers = []
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,8 +1404,8 @@ impl<T: Config> Pallet<T> {
///
/// The caller assumes that the pallet will accept regular outbound message to the sibling
/// `target_parachain` after this call. No other assumptions are made.
#[cfg(feature = "runtime-benchmarks")]
pub fn open_outbound_hrmp_channel_for_benchmarks(target_parachain: ParaId) {
#[cfg(any(feature = "runtime-benchmarks", feature = "test-helpers"))]
pub fn open_outbound_hrmp_channel_for_benchmarks_or_tests(target_parachain: ParaId) {
Comment thread
ggwpez marked this conversation as resolved.
Outdated
RelevantMessagingState::<T>::put(MessagingStateSnapshot {
dmq_mqc_head: Default::default(),
relay_dispatch_queue_remaining_capacity: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/xcmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pallet-balances = { path = "../../../substrate/frame/balances" }
xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/xcm-builder" }

# Cumulus
cumulus-pallet-parachain-system = { path = "../parachain-system" }
cumulus-pallet-parachain-system = { path = "../parachain-system", features = ["parameterized-consensus-hook", "test-helpers"] }

[features]
default = [ "std" ]
Expand Down
22 changes: 21 additions & 1 deletion cumulus/pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use super::*;
use cumulus_primitives_core::XcmpMessageHandler;
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;

#[test]
Expand Down Expand Up @@ -341,3 +341,23 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
);
});
}

#[test]
fn xcmp_queue_send_xcm_works() {
new_test_ext().execute_with(|| {
let dest = (Parent, X1(Parachain(12345))).into();
let msg = Xcm(vec![ClearOrigin]);

// try to send without opened HRMP channel to the para_id 12345
assert_eq!(
send_xcm::<XcmpQueue>(dest, msg.clone()),
Err(SendError::Transport("NoChannel")),
);

// open HRMP channel to the para_id 12345
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(12345.into());

// now send works
assert_ok!(send_xcm::<XcmpQueue>(dest, msg));
Comment thread
ggwpez marked this conversation as resolved.
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ impl_runtime_apis! {
) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) {
use cumulus_primitives_core::XcmpMessageSource;
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::<
Runtime,
BridgeGrandpaWococoInstance,
Expand Down Expand Up @@ -1113,7 +1113,7 @@ impl_runtime_apis! {
) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) {
use cumulus_primitives_core::XcmpMessageSource;
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::<
Runtime,
BridgeGrandpaRococoInstance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub mod benchmarks {
impl<I: Get<u32>> EnsureSuccessful for OpenHrmpChannel<I> {
fn ensure_successful() {
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())
}
}
}
Expand Down