Add guard check for signing algorithm (#2278)

Previously unsupported algorithm would not throw exceptions.

Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
This commit is contained in:
Wo Jake
2023-05-17 04:28:23 +08:00
committed by GitHub
parent 4cca7c9088
commit 6b1ac0bd4f
3 changed files with 15 additions and 0 deletions

View File

@@ -57,6 +57,15 @@ describe('Wallet', function () {
assert.isTrue(wallet.classicAddress.startsWith(classicAddressPrefix))
})
it('generates a new wallet using an invalid/unknown algorithm', function () {
const algorithm = 'test'
assert.throws(() => {
// @ts-expect-error -- We know it is an invalid algorithm
Wallet.generate(algorithm)
}, /Invalid cryptographic signing algorithm/u)
})
it('generates a new wallet using algorithm ecdsa-secp256k1', function () {
const algorithm = ECDSA.secp256k1
const wallet = Wallet.generate(algorithm)