From 8185fc90b7dc220419878da448192f8b208a4121 Mon Sep 17 00:00:00 2001 From: gorka Date: Wed, 1 Sep 2021 10:39:05 +0200 Subject: [PATCH 1/2] Add setter configurable only fior benchmarking or tests --- primitives/runtime/src/traits.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 15ca897e618e2..51ba4fb5f9ce1 100644 --- a/primitives/runtime/src/traits.rs +++ b/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(any(feature = "runtime-benchmarks", test))] + fn set_block_number(_block: Self::BlockNumber) {} } #[cfg(test)] From be72a7eec6ba61ffc9658df903a50efb4e6531b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 8 Sep 2021 21:06:18 +0200 Subject: [PATCH 2/2] Update primitives/runtime/src/traits.rs --- primitives/runtime/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 51ba4fb5f9ce1..312a9f6331bf1 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -1591,7 +1591,7 @@ pub trait BlockNumberProvider { /// /// 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(any(feature = "runtime-benchmarks", test))] + #[cfg(feature = "runtime-benchmarks")] fn set_block_number(_block: Self::BlockNumber) {} }