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.
This commit is contained in:
parent
3da4fdb8db
commit
de04e76564
|
@ -1,4 +1,6 @@
|
||||||
use proptest::prelude::*;
|
use proptest::{arbitrary::any, prelude::*, test_runner::Config};
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
|
||||||
use crate::block::{self, Block};
|
use crate::block::{self, Block};
|
||||||
use crate::serialization::{ZcashDeserialize, ZcashDeserializeInto, ZcashSerialize};
|
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");
|
.expect("block test vector should deserialize");
|
||||||
block.header.solution.check(&block.header)?;
|
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
|
fake_header.solution
|
||||||
.check(&fake_header)
|
.check(&fake_header)
|
||||||
.expect_err("block header should not validate on randomized solution");
|
.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");
|
.expect("block test vector should deserialize");
|
||||||
block.header.solution.check(&block.header)?;
|
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
|
fake_header.solution
|
||||||
.check(&fake_header)
|
.check(&fake_header)
|
||||||
.expect_err("equihash solution should not validate on randomized input");
|
.expect_err("equihash solution should not validate on randomized input");
|
||||||
|
|
Loading…
Reference in New Issue