Skip to content

Commit

Permalink
remove frame_support_test
Browse files Browse the repository at this point in the history
  • Loading branch information
cernicc committed Nov 25, 2024
1 parent 62ea6bb commit dd02c6e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 73 deletions.
69 changes: 0 additions & 69 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag =
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2" }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2", default-features = false }
frame-support-test = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2", default-features = false }
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409-2", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ smallvec = { workspace = true }
frame-benchmarking = { workspace = true, default-features = false, optional = true }
frame-executive = { workspace = true, default-features = false }
frame-support = { workspace = true, default-features = false }
frame-support-test = { workspace = true, default-features = false, optional = true }
frame-system = { workspace = true, default-features = false }
frame-system-benchmarking = { workspace = true, default-features = false, optional = true }
frame-system-rpc-runtime-api = { workspace = true, default-features = false }
Expand Down Expand Up @@ -147,7 +146,7 @@ std = [
"xcm-executor/std",
"xcm/std",
]
testnet = ["dep:frame-support-test"]
testnet = []

runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
Expand Down
30 changes: 29 additions & 1 deletion runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,36 @@ impl pallet_randomness::Config for Runtime {
#[cfg(not(feature = "testnet"))]
type Generator = super::RandomnessSource;
#[cfg(feature = "testnet")]
type Generator = frame_support_test::TestRandomness;
type Generator = randomness_source_testnet::PredictableRandomnessSource<Self>;

type CleanupInterval = CleanupInterval;
type SeedAgeLimit = SeedAgeLimit;
}

#[cfg(feature = "testnet")]
mod randomness_source_testnet {
use codec::Decode;
use frame_support::traits::Randomness;
use frame_system::{pallet_prelude::BlockNumberFor, Config, Pallet};
use sp_runtime::traits::TrailingZeroInput;
use sp_std::marker::PhantomData;

/// Randomness source that always returns same random value based on the
/// subject used.
///
/// ! USE THIS ONLY IN TESTNET !
pub struct PredictableRandomnessSource<T>(PhantomData<T>);
impl<Output, T> Randomness<Output, BlockNumberFor<T>> for PredictableRandomnessSource<T>
where
Output: Decode + Default,
T: Config,
{
fn random(subject: &[u8]) -> (Output, BlockNumberFor<T>) {
(
Output::decode(&mut TrailingZeroInput::new(subject)).unwrap_or_default(),
// This means the the randomness can be used immediately.
Pallet::<T>::block_number(),
)
}
}
}

0 comments on commit dd02c6e

Please sign in to comment.