mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +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:
@@ -14,9 +14,9 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::*;
|
||||
use cumulus_primitives_core::XcmpMessageHandler;
|
||||
use cumulus_primitives_core::{ParaId, 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]
|
||||
@@ -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));
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user