From d8467f6cced45d8e9d555b2402934bf953704d75 Mon Sep 17 00:00:00 2001 From: Tristan <122918260+TAdev0@users.noreply.github.com> Date: Tue, 7 May 2024 11:39:45 +0200 Subject: [PATCH] Improve Scope Usage Consistence in all Tests (#387) * improve tests scope consistence * address comment * missing tfatal --- .../zero/zerohint_dictionaries_test.go | 10 +- pkg/hintrunner/zero/zerohint_ec_test.go | 136 ++++++++---------- pkg/hintrunner/zero/zerohint_math_test.go | 48 ------- pkg/hintrunner/zero/zerohint_memcpy_test.go | 3 - .../zero/zerohint_signature_test.go | 27 ---- pkg/hintrunner/zero/zerohint_usort_test.go | 13 +- 6 files changed, 71 insertions(+), 166 deletions(-) diff --git a/pkg/hintrunner/zero/zerohint_dictionaries_test.go b/pkg/hintrunner/zero/zerohint_dictionaries_test.go index 3658e13b..c2615dd1 100644 --- a/pkg/hintrunner/zero/zerohint_dictionaries_test.go +++ b/pkg/hintrunner/zero/zerohint_dictionaries_test.go @@ -13,7 +13,10 @@ func TestZeroHintDictionaries(t *testing.T) { { operanders: []*hintOperander{}, ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{"keys": []fp.Element{}}) + err := ctx.ScopeManager.AssignVariable("keys", []fp.Element{}) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newSquashDictInnerAssertLenKeysHint() @@ -23,7 +26,10 @@ func TestZeroHintDictionaries(t *testing.T) { { operanders: []*hintOperander{}, ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{"keys": []fp.Element{*feltUint64(1), *feltUint64(2)}}) + err := ctx.ScopeManager.AssignVariable("keys", []fp.Element{*feltUint64(1), *feltUint64(2)}) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newSquashDictInnerAssertLenKeysHint() diff --git a/pkg/hintrunner/zero/zerohint_ec_test.go b/pkg/hintrunner/zero/zerohint_ec_test.go index 1ed3f332..5a7b1c5c 100644 --- a/pkg/hintrunner/zero/zerohint_ec_test.go +++ b/pkg/hintrunner/zero/zerohint_ec_test.go @@ -23,9 +23,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: feltString("0x2ff0384422a3f45ed1229a")}, {Name: "y.d2", Kind: apRelative, Value: feltString("0x483ada7726a3c4655da4f")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -40,9 +37,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -58,9 +52,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -76,9 +67,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, {Name: "y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -94,9 +82,6 @@ func TestZeroHintEc(t *testing.T) { // GetSecPBig() % fp.Modulus() {Name: "y.d2", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -112,9 +97,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, {Name: "y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -130,9 +112,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, {Name: "y.d2", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -148,9 +127,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "y.d2", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -166,9 +142,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, {Name: "y.d2", Kind: apRelative, Value: feltString("3618502788666127798953978732740734578953660990361066340291730267696802036752")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -183,9 +156,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "y.d1", Kind: apRelative, Value: feltString("100")}, {Name: "y.d2", Kind: apRelative, Value: feltString("10001")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcNegateHint(ctx.operanders["x.d0"]) }, @@ -200,7 +170,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // GetSecPBig() % fp.Modulus() but with first digit 3 replaced with 7 value := bigIntString("7618502788666127798953978732740734578953660990361066340291730267696802036752", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -214,7 +187,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // GetSecPBig() % fp.Modulus() value := bigIntString("3618502788666127798953978732740734578953660990361066340291730267696802036752", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -226,7 +202,10 @@ func TestZeroHintEc(t *testing.T) { {Name: "res", Kind: uninitialized}, }, ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{"value": big.NewInt(123456)}) + err := ctx.ScopeManager.AssignVariable("value", big.NewInt(123456)) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -238,7 +217,10 @@ func TestZeroHintEc(t *testing.T) { {Name: "res", Kind: uninitialized}, }, ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{"value": big.NewInt(-123456)}) + err := ctx.ScopeManager.AssignVariable("value", big.NewInt(-123456)) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -252,7 +234,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // 2**86 - 1 value := bigIntString("77371252455336267181195263", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -266,7 +251,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // 2**86 value := bigIntString("77371252455336267181195264", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -280,7 +268,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // 2**86 + 1 value := bigIntString("77371252455336267181195265", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -292,7 +283,10 @@ func TestZeroHintEc(t *testing.T) { {Name: "res", Kind: uninitialized}, }, ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{"value": big.NewInt(0)}) + err := ctx.ScopeManager.AssignVariable("value", big.NewInt(0)) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -306,7 +300,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // (2**86 - 1) * 2 value := bigIntString("154742504910672534362390526", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -320,7 +317,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // 2**86 * 2 value := bigIntString("154742504910672534362390528", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -334,7 +334,10 @@ func TestZeroHintEc(t *testing.T) { ctxInit: func(ctx *hinter.HintRunnerContext) { // (2**86 + 1) * 2 value := bigIntString("154742504910672534362390530", 10) - ctx.ScopeManager.EnterScope(map[string]any{"value": value}) + err := ctx.ScopeManager.AssignVariable("value", value) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newNondetBigint3V1Hint(ctx.operanders["res"]) @@ -352,7 +355,10 @@ func TestZeroHintEc(t *testing.T) { y0Big := big.NewInt(10) secPBig, _ := secp_utils.GetSecPBig() - ctx.ScopeManager.EnterScope(map[string]any{"slope": slopeBig, "x0": x0Big, "new_x": new_xBig, "y0": y0Big, "SECP_P": &secPBig}) + err := ctx.ScopeManager.AssignVariables(map[string]any{"slope": slopeBig, "x0": x0Big, "new_x": new_xBig, "y0": y0Big, "SECP_P": &secPBig}) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newFastEcAddAssignNewYHint() @@ -371,7 +377,10 @@ func TestZeroHintEc(t *testing.T) { y0Big := big.NewInt(10) secPBig, _ := secp_utils.GetSecPBig() - ctx.ScopeManager.EnterScope(map[string]any{"slope": slopeBig, "x0": x0Big, "new_x": new_xBig, "y0": y0Big, "SECP_P": &secPBig}) + err := ctx.ScopeManager.AssignVariables(map[string]any{"slope": slopeBig, "x0": x0Big, "new_x": new_xBig, "y0": y0Big, "SECP_P": &secPBig}) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newFastEcAddAssignNewYHint() @@ -391,7 +400,10 @@ func TestZeroHintEc(t *testing.T) { y0Big := big.NewInt(20) secPBig, _ := secp_utils.GetSecPBig() - ctx.ScopeManager.EnterScope(map[string]any{"slope": slopeBig, "x0": x0Big, "new_x": new_xBig, "y0": y0Big, "SECP_P": &secPBig}) + err := ctx.ScopeManager.AssignVariables(map[string]any{"slope": slopeBig, "x0": x0Big, "new_x": new_xBig, "y0": y0Big, "SECP_P": &secPBig}) + if err != nil { + t.Fatal(err) + } }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newFastEcAddAssignNewYHint() @@ -422,9 +434,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point1.y.d1", Kind: apRelative, Value: feltUint64(895645646464)}, {Name: "point1.y.d2", Kind: apRelative, Value: feltUint64(211245645)}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newFastEcAddAssignNewXHint(ctx.operanders["slope.d0"], ctx.operanders["point0.x.d0"], ctx.operanders["point1.x.d0"]) }, @@ -455,9 +464,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point1.y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "point1.y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newFastEcAddAssignNewXHint(ctx.operanders["slope.d0"], ctx.operanders["point0.x.d0"], ctx.operanders["point1.x.d0"]) }, @@ -489,9 +495,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point1.y.d1", Kind: apRelative, Value: feltString("115792089237316195423570985008687907853269984665640564039457584007908834671663")}, {Name: "point1.y.d2", Kind: apRelative, Value: feltString("115792089237316195423570985008687907853269984665640564039457584007908834671663")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newFastEcAddAssignNewXHint(ctx.operanders["slope.d0"], ctx.operanders["point0.x.d0"], ctx.operanders["point1.x.d0"]) }, @@ -515,9 +518,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "point.y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleSlopeV1Hint(ctx.operanders["point.x.d0"]) }, @@ -533,9 +533,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: feltUint64(263724839599)}, {Name: "point.y.d2", Kind: apRelative, Value: feltString("1321654896123789784652346")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleSlopeV1Hint(ctx.operanders["point.x.d0"]) }, @@ -557,9 +554,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: feltUint64(1099511627776)}, {Name: "point.y.d2", Kind: apRelative, Value: feltUint64(1099511627776)}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleSlopeV1Hint(ctx.operanders["point.x.d0"]) }, @@ -579,9 +573,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: feltUint64(4)}, {Name: "point.y.d2", Kind: apRelative, Value: feltUint64(5)}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleSlopeV1Hint(ctx.operanders["point.x.d0"]) }, @@ -606,9 +597,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "point.y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleAssignNewXV1Hint(ctx.operanders["slope.d0"], ctx.operanders["point.x.d0"]) }, @@ -633,9 +621,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: feltUint64(83478234123)}, {Name: "point.y.d2", Kind: apRelative, Value: feltString("6837128718738732781737")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleAssignNewXV1Hint(ctx.operanders["slope.d0"], ctx.operanders["point.x.d0"]) }, @@ -660,9 +645,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point.y.d1", Kind: apRelative, Value: feltString("115792089237316195423570985008687907853269984665640564039457584007908834671663")}, {Name: "point.y.d2", Kind: apRelative, Value: feltString("115792089237316195423570985008687907853269984665640564039457584007908834671663")}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - hinter.InitializeScopeManager(ctx, map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newEcDoubleAssignNewXV1Hint(ctx.operanders["slope.d0"], ctx.operanders["point.x.d0"]) }, @@ -691,9 +673,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point1.y.d1", Kind: apRelative, Value: &utils.FeltZero}, {Name: "point1.y.d2", Kind: apRelative, Value: &utils.FeltZero}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newComputeSlopeV1Hint(ctx.operanders["point0.x.d0"], ctx.operanders["point1.x.d0"]) }, @@ -715,9 +694,6 @@ func TestZeroHintEc(t *testing.T) { {Name: "point1.y.d1", Kind: apRelative, Value: feltInt64(1325)}, {Name: "point1.y.d2", Kind: apRelative, Value: feltInt64(910)}, }, - ctxInit: func(ctx *hinter.HintRunnerContext) { - ctx.ScopeManager.EnterScope(map[string]any{}) - }, makeHinter: func(ctx *hintTestContext) hinter.Hinter { return newComputeSlopeV1Hint(ctx.operanders["point0.x.d0"], ctx.operanders["point1.x.d0"]) diff --git a/pkg/hintrunner/zero/zerohint_math_test.go b/pkg/hintrunner/zero/zerohint_math_test.go index 5334f7ad..0bee291c 100644 --- a/pkg/hintrunner/zero/zerohint_math_test.go +++ b/pkg/hintrunner/zero/zerohint_math_test.go @@ -25,7 +25,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(0)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltUint64(1)}, @@ -36,7 +35,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(1)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltUint64(0)}, @@ -48,7 +46,6 @@ func TestZeroHintMath(t *testing.T) { check: apValueEquals(feltUint64(0)), }, }, - "AssertLtFelt": { { operanders: []*hintOperander{ @@ -60,7 +57,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("a = 0 is not less than b = 0"), }, - { operanders: []*hintOperander{ {Name: "a", Kind: immediate, Value: feltUint64(1)}, @@ -71,7 +67,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("a = 1 is not less than b = 0"), }, - { // -10 felt is 3618502788666131213697322783095070105623107215331596699973092056135872020467 // and it will not be less than 14 in Cairo as well. @@ -84,7 +79,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("a = -10 is not less than b = 14"), }, - { operanders: []*hintOperander{ {Name: "a", Kind: fpRelative, Value: feltUint64(1)}, @@ -96,7 +90,6 @@ func TestZeroHintMath(t *testing.T) { errCheck: errorIsNil, }, }, - "AssertNotZero": { { operanders: []*hintOperander{ @@ -107,7 +100,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("assertion failed: value is zero"), }, - { operanders: []*hintOperander{ {Name: "value", Kind: fpRelative, Value: feltInt64(1353)}, @@ -118,10 +110,8 @@ func TestZeroHintMath(t *testing.T) { errCheck: errorIsNil, }, }, - "AssertNN": { // Like IsNN, but does an assertion instead. - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltInt64(2421)}, @@ -131,7 +121,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorIsNil, }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltInt64(0)}, @@ -141,7 +130,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorIsNil, }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltInt64(-2)}, @@ -152,7 +140,6 @@ func TestZeroHintMath(t *testing.T) { errCheck: errorTextContains("assertion failed: a = -2 is out of range"), }, }, - "AssertNotEqual": { // Different address values. { @@ -175,7 +162,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorIsNil, }, - // Different felt values. { operanders: []*hintOperander{ @@ -187,7 +173,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorIsNil, }, - // Mismatching types. { operanders: []*hintOperander{ @@ -209,7 +194,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("assertion failed: non-comparable values: 1, 1:1"), }, - // Same value addresses. { operanders: []*hintOperander{ @@ -221,7 +205,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("assertion failed: 1:0 = 1:0"), }, - // Same value felts. { operanders: []*hintOperander{ @@ -234,11 +217,9 @@ func TestZeroHintMath(t *testing.T) { errCheck: errorTextContains("assertion failed: -1 = -1"), }, }, - "IsNN": { // is_nn would return 1 for non-negative values, but the // hint itself writes 0 in this case (it's used as a jump condition). - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltUint64(2421)}, @@ -248,7 +229,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(0)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltUint64(0)}, @@ -258,7 +238,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(0)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltInt64(-2)}, @@ -269,10 +248,8 @@ func TestZeroHintMath(t *testing.T) { check: apValueEquals(feltUint64(1)), }, }, - "IsNNOutOfRange": { // Note that "a" is (-a - 1). - { operanders: []*hintOperander{ // (-a - 1) => (-1 - 1) => -2 @@ -283,7 +260,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(1)), }, - { operanders: []*hintOperander{ // (-a - 1) => (0 - 1) => -1 @@ -294,7 +270,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(1)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltInt64(-1)}, @@ -304,7 +279,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(0)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltAdd(&utils.FeltMax128, feltInt64(1))}, @@ -314,7 +288,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(1)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: feltAdd(&utils.FeltMax128, feltInt64(2))}, @@ -324,7 +297,6 @@ func TestZeroHintMath(t *testing.T) { }, check: apValueEquals(feltUint64(1)), }, - { operanders: []*hintOperander{ {Name: "a", Kind: apRelative, Value: &utils.FeltMax128}, @@ -335,7 +307,6 @@ func TestZeroHintMath(t *testing.T) { check: apValueEquals(feltUint64(1)), }, }, - "IsPositive": { { operanders: []*hintOperander{ @@ -347,7 +318,6 @@ func TestZeroHintMath(t *testing.T) { }, check: varValueEquals("is_positive", feltInt64(1)), }, - { operanders: []*hintOperander{ {Name: "value", Kind: apRelative, Value: feltInt64(0)}, @@ -358,7 +328,6 @@ func TestZeroHintMath(t *testing.T) { }, check: varValueEquals("is_positive", feltInt64(1)), }, - { operanders: []*hintOperander{ {Name: "value", Kind: apRelative, Value: feltInt64(-1)}, @@ -369,7 +338,6 @@ func TestZeroHintMath(t *testing.T) { }, check: varValueEquals("is_positive", feltInt64(0)), }, - { operanders: []*hintOperander{ {Name: "value", Kind: apRelative, Value: feltAdd(&utils.FeltMax128, feltInt64(-1))}, @@ -380,7 +348,6 @@ func TestZeroHintMath(t *testing.T) { }, check: varValueEquals("is_positive", feltInt64(1)), }, - { operanders: []*hintOperander{ {Name: "value", Kind: apRelative, Value: &utils.FeltMax128}, @@ -391,7 +358,6 @@ func TestZeroHintMath(t *testing.T) { }, check: varValueEquals("is_positive", feltInt64(0)), }, - { operanders: []*hintOperander{ {Name: "value", Kind: apRelative, Value: feltAdd(&utils.FeltMax128, feltInt64(1))}, @@ -403,10 +369,8 @@ func TestZeroHintMath(t *testing.T) { check: varValueEquals("is_positive", feltInt64(0)), }, }, - "SplitIntAssertRange": { // Zero value - assertion failed, any other - nothing. - { operanders: []*hintOperander{ {Name: "value", Kind: apRelative, Value: feltInt64(1)}, @@ -416,7 +380,6 @@ func TestZeroHintMath(t *testing.T) { }, errCheck: errorTextContains("split_int(): value is out of range"), }, - { operanders: []*hintOperander{ {Name: "value", Kind: fpRelative, Value: feltInt64(0)}, @@ -427,11 +390,9 @@ func TestZeroHintMath(t *testing.T) { errCheck: errorIsNil, }, }, - "SplitIntHint": { // Performs value%base and stores that to output. // Asserts output