diff --git a/cumulus/pallets/xcmp-queue/src/lib.rs b/cumulus/pallets/xcmp-queue/src/lib.rs index cab3a18e42..057da50d72 100644 --- a/cumulus/pallets/xcmp-queue/src/lib.rs +++ b/cumulus/pallets/xcmp-queue/src/lib.rs @@ -33,7 +33,7 @@ mod mock; #[cfg(test)] mod tests; -use codec::{Decode, DecodeAll, DecodeLimit, Encode}; +use codec::{Decode, DecodeLimit, Encode}; use cumulus_primitives_core::{ relay_chain::BlockNumber as RelayBlockNumber, ChannelStatus, GetChannelInfo, MessageSendError, ParaId, XcmpMessageFormat, XcmpMessageHandler, XcmpMessageSource, @@ -538,26 +538,24 @@ impl Pallet { XcmpMessageFormat::ConcatenatedEncodedBlob => { while !remaining_fragments.is_empty() { last_remaining_fragments = remaining_fragments; - match >::decode_all(&mut remaining_fragments) { - Ok(blob) if remaining_fragments.len() < last_remaining_fragments.len() => { - let weight = max_weight - weight_used; - match Self::handle_blob_message(sender, sent_at, blob, weight) { - Ok(used) => weight_used = weight_used.saturating_add(used), - Err(true) => { - // That message didn't get processed this time because of being - // too heavy. We leave it around for next time and bail. - remaining_fragments = last_remaining_fragments; - break - }, - Err(false) => { - // Message invalid; don't attempt to retry - }, - } - }, - _ => { - debug_assert!(false, "Invalid incoming blob message data"); - remaining_fragments = &b""[..]; - }, + + if let Ok(blob) = >::decode(&mut remaining_fragments) { + let weight = max_weight - weight_used; + match Self::handle_blob_message(sender, sent_at, blob, weight) { + Ok(used) => weight_used = weight_used.saturating_add(used), + Err(true) => { + // That message didn't get processed this time because of being + // too heavy. We leave it around for next time and bail. + remaining_fragments = last_remaining_fragments; + break + }, + Err(false) => { + // Message invalid; don't attempt to retry + }, + } + } else { + debug_assert!(false, "Invalid incoming blob message data"); + remaining_fragments = &b""[..]; } } }, diff --git a/cumulus/pallets/xcmp-queue/src/tests.rs b/cumulus/pallets/xcmp-queue/src/tests.rs index bb352e69ff..59726172eb 100644 --- a/cumulus/pallets/xcmp-queue/src/tests.rs +++ b/cumulus/pallets/xcmp-queue/src/tests.rs @@ -46,10 +46,12 @@ fn bad_message_is_handled() { }); } +/// Tests that a blob message is handled. Currently this isn't implemented and panics when debug assertions +/// are enabled. When this feature is enabled, this test should be rewritten properly. #[test] -#[should_panic = "Invalid incoming blob message data"] +#[should_panic = "Blob messages not handled."] #[cfg(debug_assertions)] -fn other_bad_message_is_handled() { +fn handle_blob_message() { new_test_ext().execute_with(|| { let bad_data = vec![ 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 64, 239, @@ -58,7 +60,6 @@ fn other_bad_message_is_handled() { ]; InboundXcmpMessages::::insert(ParaId::from(1000), 1, bad_data); let format = XcmpMessageFormat::ConcatenatedEncodedBlob; - // This should exit with an error. XcmpQueue::process_xcmp_message(1000.into(), (1, format), 10_000_000_000, 10_000_000_000); }); }