Skip to content

Commit

Permalink
Snowbridge benchmark tests fix (#3424)
Browse files Browse the repository at this point in the history
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!>
  • Loading branch information
claravanstaden authored Feb 27, 2024
1 parent f5de090 commit 94c54d5
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ use polkadot_runtime_common::prod_or_fast;

#[cfg(feature = "runtime-benchmarks")]
use benchmark_helpers::DoNothingRouter;
#[cfg(not(feature = "runtime-benchmarks"))]
use bridge_hub_common::BridgeHubMessageRouter;

/// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>;
Expand Down Expand Up @@ -367,11 +365,15 @@ parameter_types! {
impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
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 =
pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = BridgeHubMessageRouter<
#[cfg(not(all(not(feature = "std"), feature = "runtime-benchmarks")))]
type MessageProcessor = bridge_hub_common::BridgeHubMessageRouter<
xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
Expand Down

0 comments on commit 94c54d5

Please sign in to comment.