Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: test vectors seed #10859

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/cli/commands/src/test_vectors/tables.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use alloy_primitives::private::getrandom::getrandom;
use arbitrary::Arbitrary;
use eyre::Result;
use proptest::{
prelude::ProptestConfig,
strategy::{Strategy, ValueTree},
test_runner::TestRunner,
test_runner::{TestRng, TestRunner},
};
use proptest_arbitrary_interop::arb;
use reth_db::tables;
Expand All @@ -17,7 +18,16 @@ const PER_TABLE: usize = 1000;

/// Generates test vectors for specified `tables`. If list is empty, then generate for all tables.
pub(crate) fn generate_vectors(mut tables: Vec<String>) -> Result<()> {
let mut runner = TestRunner::new(ProptestConfig::default());
// Prepare random seed for test (same method as used by proptest)
let mut seed = [0u8; 32];
getrandom(&mut seed)?;
println!("Seed for test vectors: {:?}", seed);

// Start the runner with the seed
let config = ProptestConfig::default();
let rng = TestRng::from_seed(config.rng_algorithm, &seed);
let mut runner = TestRunner::new_with_rng(config, rng);

fs::create_dir_all(VECTORS_FOLDER)?;

macro_rules! generate_vector {
Expand Down
Loading