Skip to content

Conversation

@JonathanOppenheimer
Copy link
Member

@JonathanOppenheimer JonathanOppenheimer commented Nov 24, 2025

Syncs ava-labs/coreth#1303

  • Requesting @alarso16 as he was the original author
  • Requesting @ceyonur as he was the merging approver

@JonathanOppenheimer JonathanOppenheimer marked this pull request as ready for review November 25, 2025 06:55
@JonathanOppenheimer JonathanOppenheimer requested a review from a team as a code owner November 25, 2025 06:55
// "your custom test name": {
// Config: NewConfig(utils.NewUint64(3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}),
// ExpectedError: ErrYourCustomError.Error(),
// WantError: ErrYourCustomError,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this break dependent users?


var ErrCannotAddManagersBeforeDurango = errors.New("cannot add managers before Durango")
var (
ErrAdminAndEnabledAddress = errors.New("cannot set address as both admin and enabled")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these all need exported?

Comment on lines 59 to 63
if oldErr != nil {
require.ErrorContains(err, oldErr.Error())
require.ErrorIs(err, oldErr)
} else {
require.NoError(err)
}
Copy link
Contributor

@alarso16 alarso16 Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if oldErr != nil {
require.ErrorContains(err, oldErr.Error())
require.ErrorIs(err, oldErr)
} else {
require.NoError(err)
}
require.ErrorIs(err, oldErr)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the same below

_, err := allowListTest.DeployContract(unprivileged)
// The error returned is a JSON Error rather than the vm.ErrExecutionReverted error
require.ErrorContains(t, err, vm.ErrExecutionReverted.Error())
// The error returned is actually a JSON Error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other comment was more informative, and more accurately describes why we need the nolint clause than "uses upstream code"

unpacked, err := UnpackGetFeeConfigOutput(test.input, test.skipLenCheck)
if test.expectedErr != "" {
require.ErrorContains(t, err, test.expectedErr)
require.ErrorContains(t, err, test.expectedErr) //nolint:forbidigo // uses upstream code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, you should wrap the error returned by UnpackGetFeeConfigOutput and check for that error

unpacked, err2 := UnpackSetFeeConfigInput(input, true)
if err != nil {
require.ErrorContains(t, err2, err.Error())
require.Equal(t, err.Error(), err2.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use ErrorIs?

Comment on lines 337 to 341
if err != nil {
require.ErrorContains(t, err2, err.Error())
require.ErrorIs(t, err2, err)
return
}
require.NoError(t, err2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
require.ErrorContains(t, err2, err.Error())
require.ErrorIs(t, err2, err)
return
}
require.NoError(t, err2)
require.ErrorIs(t, err2, err)
if err != nil {
return
}

this applies to to whole file

unpackedAddress, unpackedAmount, err := UnpackMintNativeCoinInput(test.input, test.strictMode)
if test.expectedErr != "" {
require.ErrorContains(t, err, test.expectedErr)
require.ErrorContains(t, err, test.expectedErr) //nolint:forbidigo // uses upstream code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, you should be able to fix this

Comment on lines 146 to 150
if err != nil {
require.ErrorContains(t, err2, err.Error())
require.ErrorIs(t, err2, err)
return
}
require.NoError(t, err2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the NoError by moving the ErrorIs outside of the if statement


var (
_ Backend = (*backend)(nil)
ErrValidateBlock = errors.New("failed to validate block message")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these have to be exported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants