Skip to content
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

Merged
merged 2 commits into from
Aug 25, 2021

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Aug 17, 2021

The signTypedData and recoverTypedSignature functions have been thoroughly tested, using all three versions. Older redundant tests have been removed.

@Gudahtt Gudahtt requested a review from a team as a code owner August 17, 2021 19:21
@Gudahtt Gudahtt force-pushed the add-sign-typed-data-tests branch from 2222a63 to fbff3dd Compare August 17, 2021 19:24
'0',
'0x0',
Number.MAX_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER,
Copy link
Member Author

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,
Copy link
Member Author

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.

// atomic types supported by EIP-712:
address: [
'0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
'0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbBbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', // no apparent maximum length
Copy link
Member Author

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',
Copy link
Member Author

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.

@Gudahtt Gudahtt force-pushed the add-sign-typed-data-tests branch from fbff3dd to 062a0f0 Compare August 19, 2021 18:46
The `signTypedData` and `recoverTypedSignature` functions have been
thoroughly tested, using all three versions. Older redundant tests
have been removed.
@Gudahtt Gudahtt force-pushed the add-sign-typed-data-tests branch from 062a0f0 to b4c7f12 Compare August 24, 2021 21:13
@Gudahtt
Copy link
Member Author

Gudahtt commented Aug 24, 2021

This has just been rebased to resolve conflicts.

@rekmarks rekmarks mentioned this pull request Aug 25, 2021
Copy link
Member

@rekmarks rekmarks left a 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 😅

src/index.test.ts Show resolved Hide resolved
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

LGTM!

@Gudahtt Gudahtt merged commit 453c499 into main Aug 25, 2021
@Gudahtt Gudahtt deleted the add-sign-typed-data-tests branch August 25, 2021 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants