-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
accounts/abi: fix panic in MethodById lookup. Fixes #17797 #17798
Conversation
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.
LGTM, just a minor code style commment.
@@ -137,6 +137,9 @@ func (abi *ABI) UnmarshalJSON(data []byte) error { | |||
// MethodById looks up a method by the 4-byte id | |||
// returns nil if none found | |||
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) { | |||
if len(sigdata) < 4 { |
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.
Please use a constant name instead of a hardcoded number, something like MethodIdLength
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.
Ahmm.. really? MethodById looks up a method by the 4-byte id
-- it's a 4-byte id, do we really have to make it generic for N-byte ids?
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.
it's not about being generic (a variable) but documenting (a constant name). Alright, it's not a blocker let's move on.
accounts/abi/abi_test.go
Outdated
} | ||
} | ||
|
||
func TestABI_MethodByIdEmpty(t *testing.T) { |
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.
I guess this is a leftover from a previous test, and that you moved the test to TestABI_MethodById
? Anyhow, no need to commit an empty function.
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.
Oops
Fixed, squashed |
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.
LGTM
Trivial fix,