Skip to content

Commit

Permalink
fix: add more tests for FixedBytesEncoder (#165)
Browse files Browse the repository at this point in the history
* add more tests

* fix tests
  • Loading branch information
menduz authored Aug 12, 2021
1 parent bf45735 commit bf3b579
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/abi/coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ class CoderFixedBytes extends Coder {
}

result.set(data)
} catch (error) {
} catch (err) {
throw error('invalid ' + this.name + ' value. Use hex strings or Uint8Array', INVALID_ARGUMENT, {
arg: this.localName,
coderType: this.name,
value: error.value || value,
details: error.message
value: err.value || value,
details: err.message
})
}

Expand Down
14 changes: 13 additions & 1 deletion test/integration.catalyst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@ function doTest(requestManager: RequestManager) {
console.log(`> Tx: ${CatalystContract.transactionHash}`)
})

it('getCatalyst', async function () {
it('getCatalyst uint8array(32)', async function () {
const t = await CatalystContract.catalystById(new Uint8Array(32))
console.log('getCatalyst => ', t)
})

it('getCatalyst 0x0{64}', async function () {
const t = await CatalystContract.catalystById('0x0000000000000000000000000000000000000000000000000000000000000000')
console.log('getCatalyst => ', t)
})

it('getCatalyst 0x0 should fail', async function () {
await expect(() => CatalystContract.catalystById('0x0')).rejects.toThrow()
})

it('getCatalyst 0x00 should not fail', async function () {
await CatalystContract.catalystById('0x00')
})
}

0 comments on commit bf3b579

Please sign in to comment.