Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
fix assertThrows to check against ctor not message
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay committed Feb 1, 2023
1 parent 2455efe commit 53fce75
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions util/ss58.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,24 @@ for (
}

Deno.test("ss58.encode invalid public key length", () => {
assertThrows(
() => ss58.encode(0, alice.publicKey.slice(0, 30)),
ss58.InvalidPublicKeyLengthError.prototype.message,
)
assertThrows(() => ss58.encode(0, alice.publicKey.slice(0, 30)), ss58.InvalidPublicKeyLengthError)
})

Deno.test("ss58.encode invalid network prefix", () => {
assertThrows(
() => ss58.encode(46, alice.publicKey, [0]),
ss58.InvalidNetworkPrefixError.prototype.message,
)
assertThrows(() => ss58.encode(46, alice.publicKey, [0]), ss58.InvalidNetworkPrefixError)
})

Deno.test("ss58.decodeRaw long address", () => {
assertThrows(
() => ss58.decodeRaw(new Uint8Array(40)),
ss58.InvalidAddressLengthError.prototype.message,
)
assertThrows(() => ss58.decodeRaw(new Uint8Array(40)), ss58.InvalidAddressLengthError)
})

Deno.test("ss58.decodeRaw short address", () => {
assertThrows(
() => ss58.decodeRaw(new Uint8Array(30)),
ss58.InvalidAddressLengthError.prototype.message,
)
assertThrows(() => ss58.decodeRaw(new Uint8Array(30)), ss58.InvalidAddressLengthError)
})

Deno.test("ss58.decodeRaw invalid checksum", () => {
assertThrows(
() => ss58.decodeRaw(Uint8Array.of(0, ...alice.publicKey, 255, 255)),
ss58.InvalidAddressChecksumError.prototype.message,
ss58.InvalidAddressChecksumError,
)
})

0 comments on commit 53fce75

Please sign in to comment.