-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,014 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { ClientWithEns } from '../../contracts/consts.js' | ||
import _getAbi from './_getAbi.js' | ||
|
||
it('does not propagate error when strict is false', async () => { | ||
const result = await _getAbi.decode({} as ClientWithEns, '0x1234', { | ||
strict: false, | ||
}) | ||
expect(result).toBeNull() | ||
}) | ||
|
||
it('propagates error when strict is true', async () => { | ||
await expect(_getAbi.decode({} as ClientWithEns, '0x1234', { strict: true })) | ||
.rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"Data size of 2 bytes is too small for given parameters. | ||
Params: (uint256, bytes) | ||
Data: 0x1234 (2 bytes) | ||
Version: [email protected]" | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { ClientWithEns } from '../../contracts/consts.js' | ||
import _getAddr from './_getAddr.js' | ||
|
||
it('does not propagate error when strict is false', async () => { | ||
const result = await _getAddr.decode({} as ClientWithEns, '0x1234', { | ||
strict: false, | ||
}) | ||
expect(result).toBeNull() | ||
}) | ||
|
||
it('propagates error when strict is true', async () => { | ||
await expect(_getAddr.decode({} as ClientWithEns, '0x1234', { strict: true })) | ||
.rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"Data size of 2 bytes is too small for given parameters. | ||
Params: (address) | ||
Data: 0x1234 (2 bytes) | ||
Version: [email protected]" | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/ensjs/src/functions/public/_getContentHash.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { ClientWithEns } from '../../contracts/consts.js' | ||
import _getContentHash from './_getContentHash.js' | ||
|
||
it('does not propagate error when strict is false', async () => { | ||
const result = await _getContentHash.decode({} as ClientWithEns, '0x1234', { | ||
strict: false, | ||
}) | ||
expect(result).toBeNull() | ||
}) | ||
|
||
it('propagates error when strict is true', async () => { | ||
await expect( | ||
_getContentHash.decode({} as ClientWithEns, '0x1234', { strict: true }), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"Data size of 2 bytes is too small for given parameters. | ||
Params: (bytes) | ||
Data: 0x1234 (2 bytes) | ||
Version: [email protected]" | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { ClientWithEns } from '../../contracts/consts.js' | ||
import _getText from './_getText.js' | ||
|
||
it('does not propagate error when strict is false', async () => { | ||
const result = await _getText.decode({} as ClientWithEns, '0x1234', { | ||
strict: false, | ||
}) | ||
expect(result).toBeNull() | ||
}) | ||
|
||
it('propagates error when strict is true', async () => { | ||
await expect(_getText.decode({} as ClientWithEns, '0x1234', { strict: true })) | ||
.rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"Data size of 2 bytes is too small for given parameters. | ||
Params: (string) | ||
Data: 0x1234 (2 bytes) | ||
Version: [email protected]" | ||
`) | ||
}) |
Oops, something went wrong.