Skip to content

Commit

Permalink
[feat] added a default scope manager (#382)
Browse files Browse the repository at this point in the history
* added a default scope manager

* empty HintRunnerContext

* resolved deletion error

* Call assign variable zerohint_usort_test.go

* modified UsortVerifyMultiplicityAssert to call assign variable

* Add err handling

---------

Co-authored-by: Tristan <122918260+TAdev0@users.noreply.github.com>
  • Loading branch information
fishonamos and TAdev0 committed May 3, 2024
1 parent 122eb02 commit 5305bb0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions pkg/hintrunner/zero/zerohint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func runHinterTests(t *testing.T, tests map[string][]hintTestCase) {
}

ctx := &hinter.HintRunnerContext{}
hinter.InitializeScopeManager(ctx, make(map[string]any))
if tc.ctxInit != nil {
tc.ctxInit(ctx)
}
Expand Down
25 changes: 13 additions & 12 deletions pkg/hintrunner/zero/zerohint_usort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ func TestZeroHintUsort(t *testing.T) {
"UsortVerifyMultiplicityAssert": {
{
ctxInit: func(ctx *hinter.HintRunnerContext) {
ctx.ScopeManager.EnterScope(map[string]any{
"positions": []uint64{
1,
},
})
err := ctx.ScopeManager.AssignVariable("positions", []uint64{1})
if err != nil {
panic(err)
}
},
makeHinter: func(ctx *hintTestContext) hinter.Hinter {
return newUsortVerifyMultiplicityAssertHinter()
Expand All @@ -39,9 +38,10 @@ func TestZeroHintUsort(t *testing.T) {
},
{
ctxInit: func(ctx *hinter.HintRunnerContext) {
hinter.InitializeScopeManager(ctx, map[string]any{
"positions": []uint64{},
})
err := ctx.ScopeManager.AssignVariable("positions", []uint64{})
if err != nil {
panic(err)
}
},
makeHinter: func(ctx *hintTestContext) hinter.Hinter {
return newUsortVerifyMultiplicityAssertHinter()
Expand All @@ -52,11 +52,12 @@ func TestZeroHintUsort(t *testing.T) {
"UsortVerify": {
{
ctxInit: func(ctx *hinter.HintRunnerContext) {
hinter.InitializeScopeManager(ctx, map[string]any{
"positions_dict": map[fp.Element][]uint64{
*feltUint64(0): {1, 2, 3},
},
err := ctx.ScopeManager.AssignVariable("positions_dict", map[fp.Element][]uint64{
*feltUint64(0): {1, 2, 3},
})
if err != nil {
panic(err)
}
},
operanders: []*hintOperander{
{Name: "value", Kind: fpRelative, Value: feltUint64(0)},
Expand Down

0 comments on commit 5305bb0

Please sign in to comment.