-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Add TypedDataUtils.hashStruct
tests
#170
Conversation
|
cb4c5f5
to
e419505
Compare
f8bb67c
to
66ea1b2
Compare
e419505
to
16f1b8f
Compare
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.
These tests do mirror the encodeData
tests exactly, and I'm wondering why we're going through all the trouble. Given that the only operation of hashStruct
is to call ethUtil.keccak
with the return value of encodeData
. That being the case, what exactly are we testing, here?
Unless we are trying to test keccak
itself, it seems to me that this entire PR could be reduced to a single test case:
describe('hashStruct', () => {
it('hashes the result from encodeData', () => {
// set up some mocks
expect(encodeData).toHaveBeenCalledOnce();
expect(ethUtil.keccak).toHaveBeenCalledOnce();
})
})
The test should probably be instrumented such that we're convinced that keccak
is indeed called with the return value of encodeData
, but you get the idea.
I want to discuss the matter, not actually block on it.
I dismissed my previous review because I really meant it as a comment. I want to discuss the matter, but I won't ultimately block on it. |
If we were to test just that The thoroughness here might not be useful though. I did consider testing just a few representative samples. I went with the whole test suite because it seemed just as easy, and I don't know how unlikely it might be for a broken |
16f1b8f
to
cd3229c
Compare
This function should now be comprehensively tested. The tests mirror the `TypedDataUtils.encodeData` tests exactly. Any uses of `hashStruct` in the older signature tests have been removed, as they are now redundant.
cd3229c
to
0049325
Compare
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!
This function should now be comprehensively tested. The tests mirror the
TypedDataUtils.encodeData
tests exactly. Any uses ofhashStruct
in the older signature tests have been removed, as they are now redundant.