mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
Add fast-runtime Cargo Feature for Quick Test Runs (#4332)
* add fast-runtime feature for reduced session times * make democracy periods fast on fast-runtime * propagate fast-runtime feature through cargo.toml files * add fast motion and term durations to Kusama * Update runtime/westend/Cargo.toml Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * set session time to 2 minutes to avoid block production issues * formatting * update Substrate * set democracy fast periods back to 1min * set launch period and enactment period to 1 block in fast-runtime * remove unnecessary westend period configs * add prod_or_test macro to allow specifying prod, test and env values for parameter types * move prod_or_test macro into common module and use it consistently * rename macro to prod_or_fast * cargo +nightly fmt * bump impl_versions * newline Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * add note that env variable is evaluated at compile time * newline Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * newline Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * cargo fmt * impl_version: 0 * impl_version: 0 * use prod_or_fast macro for LeasePeriod and LeaseOffset * use prod_or_fast macro in WND and ROC constants Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
@@ -190,6 +190,35 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
|
||||
type MaxNominators = ConstU32<1000>;
|
||||
}
|
||||
|
||||
/// Macro to set a value (e.g. when using the `parameter_types` macro) to either a production value
|
||||
/// or to an environment variable or testing value (in case the `fast-runtime` feature is selected).
|
||||
/// Note that the environment variable is evaluated _at compile time_.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```Rust
|
||||
/// parameter_types! {
|
||||
/// // Note that the env variable version parameter cannot be const.
|
||||
/// pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "KSM_LAUNCH_PERIOD");
|
||||
/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES);
|
||||
/// }
|
||||
#[macro_export]
|
||||
macro_rules! prod_or_fast {
|
||||
($prod:expr, $test:expr) => {
|
||||
if cfg!(feature = "fast-runtime") {
|
||||
$test
|
||||
} else {
|
||||
$prod
|
||||
}
|
||||
};
|
||||
($prod:expr, $test:expr, $env:expr) => {
|
||||
if cfg!(feature = "fast-runtime") {
|
||||
core::option_env!($env).map(|s| s.parse().ok()).flatten().unwrap_or($test)
|
||||
} else {
|
||||
$prod
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod multiplier_tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user