Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Parameterize message origin in Tests #36

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ decl_test_parachains! {
XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue,
LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ decl_test_parachains! {
XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue,
LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ decl_test_parachains! {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Expand All @@ -56,6 +57,7 @@ decl_test_parachains! {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Expand Down
24 changes: 13 additions & 11 deletions cumulus/xcm/xcm-emulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

pub use codec::{Decode, Encode, EncodeLike};
pub use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};
pub use lazy_static::lazy_static;
pub use log;
pub use paste;
Expand Down Expand Up @@ -576,7 +576,7 @@ macro_rules! decl_test_parachains {
XcmpMessageHandler: $xcmp_message_handler:path,
LocationToAccountId: $location_to_account:path,
ParachainInfo: $parachain_info:path,
// MessageProcessor: $message_processor:path,
MessageOrigin: $message_origin:path,
},
pallets = {
$($pallet_name:ident: $pallet_path:path,)*
Expand Down Expand Up @@ -615,7 +615,7 @@ macro_rules! decl_test_parachains {
type LocationToAccountId = $location_to_account;
type ParachainSystem = $crate::ParachainSystemPallet<<Self as $crate::Chain>::Runtime>;
type ParachainInfo = $parachain_info;
type MessageProcessor = $crate::DefaultParaMessageProcessor<$name<N>>;
type MessageProcessor = $crate::DefaultParaMessageProcessor<$name<N>, $message_origin>;

// We run an empty block during initialisation to open HRMP channels
// and have them ready for the next block
Expand Down Expand Up @@ -1313,17 +1313,18 @@ macro_rules! decl_test_sender_receiver_accounts_parameter_types {
};
}

pub struct DefaultParaMessageProcessor<T>(PhantomData<T>);
pub struct DefaultParaMessageProcessor<T, M>(PhantomData<(T, M)>);
// Process HRMP messages from sibling paraids
impl<T> ProcessMessage for DefaultParaMessageProcessor<T>
impl<T, M> ProcessMessage for DefaultParaMessageProcessor<T, M>
where
M: codec::FullCodec + MaxEncodedLen + Clone + Eq + PartialEq + frame_support::pallet_prelude::TypeInfo + Debug,
T: Parachain,
T::Runtime: MessageQueueConfig,
<<T::Runtime as MessageQueueConfig>::MessageProcessor as ProcessMessage>::Origin:
PartialEq<CumulusAggregateMessageOrigin>,
MessageQueuePallet<T::Runtime>: EnqueueMessage<CumulusAggregateMessageOrigin> + ServiceQueues,
PartialEq<M>,
MessageQueuePallet<T::Runtime>: EnqueueMessage<M> + ServiceQueues,
{
type Origin = CumulusAggregateMessageOrigin;
type Origin = M;

fn process_message(
msg: &[u8],
Expand All @@ -1340,13 +1341,14 @@ where
Ok(true)
}
}
impl<T> ServiceQueues for DefaultParaMessageProcessor<T>
impl<T, M> ServiceQueues for DefaultParaMessageProcessor<T, M>
where
M: MaxEncodedLen,
T: Parachain,
T::Runtime: MessageQueueConfig,
<<T::Runtime as MessageQueueConfig>::MessageProcessor as ProcessMessage>::Origin:
PartialEq<CumulusAggregateMessageOrigin>,
MessageQueuePallet<T::Runtime>: EnqueueMessage<CumulusAggregateMessageOrigin> + ServiceQueues,
PartialEq<M>,
MessageQueuePallet<T::Runtime>: EnqueueMessage<M> + ServiceQueues,
{
type OverweightMessageAddress = ();

Expand Down
Loading