-
Notifications
You must be signed in to change notification settings - Fork 524
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 guard check for signing algorithm #2278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write unit tests for this and also change it to the correct value ecdsa-secp256k1
Can you add a test where you pass the wrong value and check that it throws an exception? |
Please update the changelog. |
it('generates a new wallet using an invalid/unknown algorithm', function () { | ||
const algorithm = "test" | ||
|
||
assert.throws(() => { Wallet.generate(algorithm) }, /Invalid cryptographic signing algorithm/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to ignore the TypeScript check here for tests to pass
it('generates a new wallet using an invalid/unknown algorithm', function () { | ||
const algorithm = "test" | ||
|
||
assert.throws(() => { Wallet.generate(algorithm) }, /Invalid cryptographic signing algorithm/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add //@ts-expect-error
. This will allow the test to compile even though the type is wrong to simulate how it might work if using js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just cast it via as unknown as ExpectedType
note: awaiting response from @wojake |
Added `//@ts-expect-error` to allow a test to check a bad parameter.
High Level Overview of Change
Context of Change
You could put in a random string and it'll still work, we should be able to tell that the function generated a seed according to the right algorithm. Feel free to make changes to this PR since I have no clue if this works.
Type of Change
Before / After
Test Plan