Reduce the equihash proptest run time
Reduce the default number of cases run by the equihash proptests,
so they run in under 10 seconds on my machine.
Set the PROPTEST_CASES env var to override the default.
-use proptest::prelude::*;
+use proptest::{arbitrary::any, prelude::*, test_runner::Config};
+
+use std::env;
use crate::block::{self, Block};
use crate::serialization::{ZcashDeserialize, ZcashDeserializeInto, ZcashSerialize};
@@ -41,7 +43,13 @@ fn equihash_prop_test_solution() -> color_eyre::eyre::Result<()> {
.expect("block test vector should deserialize");
block.header.solution.check(&block.header)?;
- proptest!(|(fake_header in randomized_solutions(block.header))| {
+ // The equihash solution test can be really slow, so we use fewer cases by
+ // default. Set the PROPTEST_CASES env var to override this default.
+ proptest!(Config::with_cases(env::var("PROPTEST_CASES")
+ .ok()
+ .and_then(|v| v.parse().ok())
+ .unwrap_or(64)),
+ |(fake_header in randomized_solutions(block.header))| {
fake_header.solution
.check(&fake_header)
.expect_err("block header should not validate on randomized solution");
@@ -108,7 +116,11 @@ fn equihash_prop_test_input() -> color_eyre::eyre::Result<()> {
.expect("block test vector should deserialize");
block.header.solution.check(&block.header)?;
- proptest!(|(fake_header in randomized_input(block.header))| {
+ proptest!(Config::with_cases(env::var("PROPTEST_CASES")
+ .ok()
+ .and_then(|v| v.parse().ok())
+ .unwrap_or(64)),
+ |(fake_header in randomized_input(block.header))| {
fake_header.solution
.check(&fake_header)
.expect_err("equihash solution should not validate on randomized input");
