Snowbridge benchmark tests fix (#3424)

When running `cargo test -p bridge-hub-rococo-runtime --features
runtime-benchmarks`, two of the Snowbridge benchmark tests fails. The
reason is that when the runtime-benchmarks feature is enabled, the
`NoopMessageProcessor` message processor is used. The Snowbridge tests
rely on the outbound messages to be processed using the message queue,
so that we can check the expected nonce and block digest logs.

This PR changes the conditional compilation to only use
`NoopMessageProcessor` when compiling the executable to run benchmarks
against, not when running tests.

---------

Co-authored-by: claravanstaden <Cats 4 life!>
This commit is contained in:
Clara van Staden
2024-02-27 14:49:31 +02:00
committed by GitHub
parent f5de090aa5
commit 94c54d5032
@@ -102,8 +102,6 @@ use polkadot_runtime_common::prod_or_fast;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
use benchmark_helpers::DoNothingRouter; use benchmark_helpers::DoNothingRouter;
#[cfg(not(feature = "runtime-benchmarks"))]
use bridge_hub_common::BridgeHubMessageRouter;
/// The address format for describing accounts. /// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>; pub type Address = MultiAddress<AccountId, ()>;
@@ -367,11 +365,15 @@ parameter_types! {
impl pallet_message_queue::Config for Runtime { impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>; type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")] // Use the NoopMessageProcessor exclusively for benchmarks, not for tests with the
// runtime-benchmarks feature as tests require the BridgeHubMessageRouter to process messages.
// The "test" feature flag doesn't work, hence the reliance on the "std" feature, which is
// enabled during tests.
#[cfg(all(not(feature = "std"), feature = "runtime-benchmarks"))]
type MessageProcessor = type MessageProcessor =
pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>; pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
#[cfg(not(feature = "runtime-benchmarks"))] #[cfg(not(all(not(feature = "std"), feature = "runtime-benchmarks")))]
type MessageProcessor = BridgeHubMessageRouter< type MessageProcessor = bridge_hub_common::BridgeHubMessageRouter<
xcm_builder::ProcessXcmMessage< xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin, AggregateMessageOrigin,
xcm_executor::XcmExecutor<xcm_config::XcmConfig>, xcm_executor::XcmExecutor<xcm_config::XcmConfig>,