Skip to content

Commit

Permalink
feat: add test.NoFuzzing() testing option
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Mar 25, 2022
1 parent 394c987 commit 699621e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@ func (assert *Assert) ProverSucceeded(circuit frontend.Circuit, validAssignment
}
}

// TODO may not be the right place, but ensures all our tests call these minimal tests
// (like filling a witness with zeroes, or binary values, ...)
assert.Run(func(assert *Assert) {
assert.Fuzz(circuit, 5, opts...)
}, "fuzz")
if opt.fuzzing {
// TODO may not be the right place, but ensures all our tests call these minimal tests
// (like filling a witness with zeroes, or binary values, ...)
assert.Run(func(assert *Assert) {
assert.Fuzz(circuit, 5, opts...)
}, "fuzz")
}
}

// ProverSucceeded fails the test if any of the following step errored:
Expand Down Expand Up @@ -456,6 +458,7 @@ func (assert *Assert) options(opts ...TestingOption) testingConfig {
witnessSerialization: true,
backends: backend.Implemented(),
curves: ecc.Implemented(),
fuzzing: true,
}
for _, option := range opts {
err := option(&opt)
Expand Down
9 changes: 9 additions & 0 deletions test/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type testingConfig struct {
witnessSerialization bool
proverOpts []backend.ProverOption
compileOpts []frontend.CompileOption
fuzzing bool
}

// WithBackends is testing option which restricts the backends the assertions are
Expand Down Expand Up @@ -64,6 +65,14 @@ func NoSerialization() TestingOption {
}
}

// NoFuzzing is a testing option which disables fuzzing tests in assertions.
func NoFuzzing() TestingOption {
return func(opt *testingConfig) error {
opt.fuzzing = false
return nil
}
}

// WithProverOpts is a testing option which uses the given proverOpts when
// calling backend.Prover, backend.ReadAndProve and backend.IsSolved methods in
// assertions.
Expand Down

0 comments on commit 699621e

Please sign in to comment.