-
Notifications
You must be signed in to change notification settings - Fork 278
sync: coreth PR #1303 style: Use require.ErrorIs whenever possible #1875
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
base: master
Are you sure you want to change the base?
sync: coreth PR #1303 style: Use require.ErrorIs whenever possible #1875
Conversation
| // "your custom test name": { | ||
| // Config: NewConfig(utils.NewUint64(3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), | ||
| // ExpectedError: ErrYourCustomError.Error(), | ||
| // WantError: ErrYourCustomError, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user was using this template generation code and then doing a strings.Contains, then yeah I guess it would -- do we really care about that though? Is this supposed to be externally supported code? The fix is incredibly easy too -- just use errors.Is (as you're supposed to)
|
|
||
| var ErrCannotAddManagersBeforeDurango = errors.New("cannot add managers before Durango") | ||
| var ( | ||
| ErrAdminAndEnabledAddress = errors.New("cannot set address as both admin and enabled") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they do -- I just tried for all of them. They're declared in package allowlist and used in package allowlist_test
| unpacked, err2 := UnpackSetFeeConfigInput(input, true) | ||
| if err != nil { | ||
| require.ErrorContains(t, err2, err.Error()) | ||
| require.Equal(t, err.Error(), err2.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use ErrorIs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error chain are different, so ErrorIs fails.
Error: Target error should be in err chain:
expected: "invalid input length for fee config Input: 260"
in chain: "invalid input length for fee config Input: 260"
"invalid input length for fee config Input"
I didn't want to touch the old unpack config -- seems like it shouldn't be modified
|
|
||
| var ( | ||
| _ Backend = (*backend)(nil) | ||
| ErrValidateBlock = errors.New("failed to validate block message") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors are declared in package warp and used in package evm.
…r-1303-remaining-forbidigo
Syncs ava-labs/coreth#1303