Skip to content

Commit

Permalink
fix: emulated hint tests (Consensys#1083)
Browse files Browse the repository at this point in the history
* fix: include solver hints

* fix: add dummy constraint to allow plonk SRS gen
  • Loading branch information
ivokub authored Mar 12, 2024
1 parent 4ae5707 commit bb26665
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions std/math/emulated/field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/big"
"testing"

"github.com/consensys/gnark/constraint/solver"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/frontend/cs/r1cs"
"github.com/consensys/gnark/test"
Expand Down Expand Up @@ -183,7 +184,7 @@ func testHint[T FieldParams](t *testing.T) {
Denominator: ValueOf[T](b),
Expected: ValueOf[T](c),
}
assert.CheckCircuit(&circuit, test.WithValidAssignment(&witness))
assert.CheckCircuit(&circuit, test.WithValidAssignment(&witness), test.WithSolverOpts(solver.WithHints(nnaHint)))
}

func TestHint(t *testing.T) {
Expand Down Expand Up @@ -241,7 +242,7 @@ func testHintNativeInput[T FieldParams](t *testing.T) {
Denominator: b,
Expected: ValueOf[T](c),
}
assert.CheckCircuit(&circuit, test.WithValidAssignment(&witness), test.WithCurves(testCurve))
assert.CheckCircuit(&circuit, test.WithValidAssignment(&witness), test.WithCurves(testCurve), test.WithSolverOpts(solver.WithHints(nativeInputHint)))
}

func TestHintNativeInput(t *testing.T) {
Expand Down Expand Up @@ -281,6 +282,7 @@ func (c *hintNativeOutputCircuit[T]) Define(api frontend.API) error {
return err
}
api.AssertIsEqual(res[0], c.Expected)
api.AssertIsDifferent(c.Expected, 0)
return nil
}

Expand All @@ -299,7 +301,7 @@ func testHintNativeOutput[T FieldParams](t *testing.T) {
Denominator: ValueOf[T](b),
Expected: c,
}
assert.CheckCircuit(&circuit, test.WithValidAssignment(&witness), test.WithCurves(testCurve))
assert.CheckCircuit(&circuit, test.WithValidAssignment(&witness), test.WithCurves(testCurve), test.WithSolverOpts(solver.WithHints(nativeOutputHint)))
}

func TestHintNativeOutput(t *testing.T) {
Expand Down

0 comments on commit bb26665

Please sign in to comment.