-
-
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 signTypedData
and recoverTypedSignature
tests
#185
Conversation
2222a63
to
fbff3dd
Compare
'0', | ||
'0x0', | ||
Number.MAX_SAFE_INTEGER, | ||
Number.MIN_SAFE_INTEGER, |
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 had to create a separate set of example data for V1 because it differed from the V3/V4 behaviour a fair bit.
Here's the first highlight - negative unsigned data! Somehow it doesn't throw.
const signTypedDataV1ErrorExamples = { | ||
string: [ | ||
{ | ||
input: 10, |
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.
Second highlight - it doesn't accept numbers as string data. Makes sense, but it's unfortunate that V3 and V4 do.
src/index.test.ts
Outdated
// atomic types supported by EIP-712: | ||
address: [ | ||
'0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', | ||
'0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbBbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', // no apparent maximum length |
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.
Third highlight - infinite-length addresses!
], | ||
address: [ | ||
{ | ||
input: 'bBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', |
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.
Fourth highlight - apparently unprefixed addresses are not allowed with V1. They are accepted by V3/V4.
fbff3dd
to
062a0f0
Compare
The `signTypedData` and `recoverTypedSignature` functions have been thoroughly tested, using all three versions. Older redundant tests have been removed.
062a0f0
to
b4c7f12
Compare
This has just been rebased to resolve conflicts. |
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.
This looks good! Excited to close this chapter.
I reviewed the V1
and recoverTypedSignature
tests by hand, and relied extensively on diff
to compare most of the V3
and V4
tests (which are indeed mirror images of their encodeData
and eip712Hash
counterparts).
I've left one inline question / comment and requested some additional changes in #191. Otherwise, my only general request is that we split up this humongous file in a follow-up 😅
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!
The
signTypedData
andrecoverTypedSignature
functions have been thoroughly tested, using all three versions. Older redundant tests have been removed.