Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundancy in zerohint_utils_test.go file #410

Closed
TAdev0 opened this issue May 13, 2024 · 0 comments · Fixed by #411
Closed

Redundancy in zerohint_utils_test.go file #410

TAdev0 opened this issue May 13, 2024 · 0 comments · Fixed by #411

Comments

@TAdev0
Copy link
Member

TAdev0 commented May 13, 2024

zerohint_utils_test.go file defines the following functions:

func varValueEquals(varName string, expected *fp.Element) func(t *testing.T, ctx *hintTestContext) {
	return func(t *testing.T, ctx *hintTestContext) {
		o := ctx.operanders[varName]
		addr, err := o.GetAddress(ctx.vm)
		if err != nil {
			t.Fatal(err)
		}
		actualFelt, err := ctx.vm.Memory.ReadFromAddressAsElement(&addr)
		if err != nil {
			t.Fatal(err)
		}
		if !actualFelt.Equal(expected) {
			t.Fatalf("%s value mismatch:\nhave: %v\nwant: %v", varName, &actualFelt, expected)
		}
	}
}

func varAddrResolvedValueEquals(varName string, expected *fp.Element) func(t *testing.T, ctx *hintTestContext) {
	return func(t *testing.T, ctx *hintTestContext) {
		o := ctx.operanders[varName]
		addr, err := o.GetAddress(ctx.vm)
		require.NoError(t, err)
		actualFelt, err := ctx.vm.Memory.ReadFromAddressAsElement(&addr)
		require.NoError(t, err)
		require.Equal(t, &actualFelt, expected, "%s value mismatch:\nhave: %v\nwant: %v", varName, &actualFelt, expected)
	}
}

Both of them do the exact same thing, but handle error slightly differently. We can remove one of them.
varAddrResolvedValueEquals is used for only for usort hint , i supposed it has been created by some external contributor but it was not needed

@TAdev0 TAdev0 changed the title Redundancy in _zerohint_utils_test.go_ file Redundancy in zerohint_utils_test.go file May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant