From b9e968fb3f5cc42f320513bf21856ebd04c6690d Mon Sep 17 00:00:00 2001 From: girazoki Date: Thu, 9 Sep 2021 12:45:16 +0200 Subject: [PATCH] Add setter configurable only for benchmarking or tests (#9668) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add setter configurable only fior benchmarking or tests * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher --- substrate/primitives/runtime/src/traits.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/substrate/primitives/runtime/src/traits.rs b/substrate/primitives/runtime/src/traits.rs index 15ca897e61..312a9f6331 100644 --- a/substrate/primitives/runtime/src/traits.rs +++ b/substrate/primitives/runtime/src/traits.rs @@ -1585,6 +1585,14 @@ pub trait BlockNumberProvider { /// ``` /// . fn current_block_number() -> Self::BlockNumber; + + /// Utility function only to be used in benchmarking scenarios, to be implemented optionally, + /// else a noop. + /// + /// It allows for setting the block number that will later be fetched + /// This is useful in case the block number provider is different than System + #[cfg(feature = "runtime-benchmarks")] + fn set_block_number(_block: Self::BlockNumber) {} } #[cfg(test)]