Skip to content

Commit 124b693

Browse files
authored
test: refactor crumb test to standard path (#1648)
1 parent b53af63 commit 124b693

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

internal/backend/circuits/crumb.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package circuits
2+
3+
import (
4+
"math/rand/v2"
5+
6+
"github.com/consensys/gnark/frontend"
7+
)
8+
9+
type isCrumbCircuit struct {
10+
C []frontend.Variable
11+
}
12+
13+
func (circuit *isCrumbCircuit) Define(api frontend.API) error {
14+
for _, x := range circuit.C {
15+
api.AssertIsCrumb(x)
16+
}
17+
return nil
18+
}
19+
20+
func init() {
21+
c := []frontend.Variable{0, 1, 2, 3}
22+
good := []frontend.Circuit{
23+
&isCrumbCircuit{C: c},
24+
}
25+
addNewEntry("isCrumb/case=good", &isCrumbCircuit{C: make([]frontend.Variable, len(c))}, good, nil, nil)
26+
var bad []frontend.Circuit
27+
for n := 0; n < 20; n++ {
28+
x := rand.IntN(65531) + 4 //#nosec G404 weak rng OK for test
29+
bad = append(bad, &isCrumbCircuit{C: []frontend.Variable{x}})
30+
}
31+
addNewEntry("isCrumb/case=bad", &isCrumbCircuit{C: []frontend.Variable{nil}}, nil, bad, nil)
32+
}

test/api_assertions_test.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)