Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -42,6 +42,7 @@ decl_test_parachains! {
LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_rococo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
DigestProvider: (),
},
pallets = {
PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ decl_test_parachains! {
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
DigestProvider: (),
},
pallets = {
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
Expand Down
16 changes: 12 additions & 4 deletions cumulus/xcm/xcm-emulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ pub use cumulus_primitives_core::AggregateMessageOrigin as CumulusAggregateMessa
pub use frame_support::{
assert_ok,
sp_runtime::{
traits::{Dispatchable, Header as HeaderT},
traits::{Convert, Dispatchable, Header as HeaderT},
Digest,
DispatchResult,
},
traits::{
Expand Down Expand Up @@ -108,7 +109,6 @@ thread_local! {
/// Most recent `HeadData` of each parachain, encoded.
pub static LAST_HEAD: RefCell<HashMap<String, HashMap<u32, HeadData>>> = RefCell::new(HashMap::new());
}

pub trait CheckAssertion<Origin, Destination, Hops, Args>
where
Origin: Chain + Clone,
Expand Down Expand Up @@ -264,6 +264,7 @@ pub trait Parachain: Chain {
type ParachainInfo: Get<ParaId>;
type ParachainSystem;
type MessageProcessor: ProcessMessage + ServiceQueues;
type DigestProvider: sp_runtime::traits::Convert<BlockNumberFor<Self::Runtime>, Digest>;

fn init();

Expand Down Expand Up @@ -599,6 +600,7 @@ macro_rules! decl_test_parachains {
LocationToAccountId: $location_to_account:path,
ParachainInfo: $parachain_info:path,
MessageOrigin: $message_origin:path,
$( DigestProvider: $digest_provider:ty, )?
},
pallets = {
$($pallet_name:ident: $pallet_path:path,)*
Expand Down Expand Up @@ -639,6 +641,7 @@ macro_rules! decl_test_parachains {
type ParachainSystem = $crate::ParachainSystemPallet<<Self as $crate::Chain>::Runtime>;
type ParachainInfo = $parachain_info;
type MessageProcessor = $crate::DefaultParaMessageProcessor<$name<N>, $message_origin>;
$crate::decl_test_parachains!(@inner_digest_provider $($digest_provider)?);

// We run an empty block during initialisation to open HRMP channels
// and have them ready for the next block
Expand All @@ -657,7 +660,7 @@ macro_rules! decl_test_parachains {
}

fn new_block() {
use $crate::{Chain, HeadData, Network, Hooks, Encode, Parachain, TestExt};
use $crate::{Chain, Convert, HeadData, Network, Hooks, Encode, Parachain, TestExt};

let para_id = Self::para_id().into();

Expand All @@ -677,7 +680,10 @@ macro_rules! decl_test_parachains {
.expect("network not initialized?")
.clone()
);
<Self as Chain>::System::initialize(&block_number, &parent_head_data.hash(), &Default::default());

let digest = <Self as Parachain>::DigestProvider::convert(block_number);

<Self as Chain>::System::initialize(&block_number, &parent_head_data.hash(), &digest);
<<Self as Parachain>::ParachainSystem as Hooks<$crate::BlockNumberFor<Self::Runtime>>>::on_initialize(block_number);

let _ = <Self as Parachain>::ParachainSystem::set_validation_data(
Expand Down Expand Up @@ -734,6 +740,8 @@ macro_rules! decl_test_parachains {
$crate::__impl_check_assertion!($name, N);
)+
};
( @inner_digest_provider $digest_provider:ty ) => { type DigestProvider = $digest_provider; };
( @inner_digest_provider /* none */ ) => { type DigestProvider = (); };
}

#[macro_export]
Expand Down
Loading