Skip to content
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

[Bug] Account.isValidPair throwing errors on invalid seed lengths and seed chars #151

Closed
sno2 opened this issue Apr 20, 2021 · 1 comment · Fixed by #152
Closed

[Bug] Account.isValidPair throwing errors on invalid seed lengths and seed chars #151

sno2 opened this issue Apr 20, 2021 · 1 comment · Fixed by #152
Labels
PR Reward - 50 Reward in coin(s)

Comments

@sno2
Copy link
Contributor

sno2 commented Apr 20, 2021

Describe the bug
Account.isValidPair static method is throwing errors on invalid keys (i.e. bad length, invalid hex chars).

To Reproduce
Steps to reproduce the behavior:

  1. Clone the project
  2. Go to tests/account.test.js
  3. Add the following line of code in the test labeled "isValidPair(signingKey, accountNumber)":
expect(Account.isValidPair("asdf", "aasdf2")).toBeFalsy();
  1. Run npm test
  2. The following error happens:
 FAIL  tests/account.test.js (5.628 s)
  ● Account › isValidPair(signingKey, accountNumber)

    bad seed size

      2315 |     key: "fromSigningKey",
      2316 |     value: function fromSigningKey(signingKey) {
    > 2317 |       var _tweetnacl$sign$keyPa = tweetnacl.sign.keyPair.fromSeed(hexToUint8Array(signingKey)),
           |                                                          ^
      2318 |           accountNumber = _tweetnacl$sign$keyPa.publicKey,
      2319 |           signingKey_ = _tweetnacl$sign$keyPa.secretKey;
      2320 | 

      at Function.fromSeed (node_modules/tweetnacl/nacl-fast.js:2329:11)
      at Function.fromSigningKey (dist/index.js:2317:58)
      at new Account (dist/index.js:2228:29)
      at Function.isValidPair (dist/index.js:2350:14)
      at Object.<anonymous> (tests/account.test.js:47:20)

Expected behavior
Account.isValidPair should just return whether the pair is valid or not, no matter whether the strings are the wrong size or don't include valid hex characters. It should not be throwing any errors at all.

@sno2 sno2 changed the title [Task] Use try-catch in Account.isValidPair static method [Bug] Use try-catch in Account.isValidPair static method Apr 20, 2021
@sno2
Copy link
Contributor Author

sno2 commented Apr 20, 2021

I've got this.

@sno2 sno2 changed the title [Bug] Use try-catch in Account.isValidPair static method [Bug] Account.isValidPair throwing errors on invalid seed lengths and seed chars Apr 20, 2021
@zinoadidi zinoadidi added the PR Reward - 50 Reward in coin(s) label Apr 22, 2021
zinoadidi pushed a commit that referenced this issue Apr 22, 2021
* fix(#151): stop `Account.isValidPair` from throwing

* feat: add `Account.isValidPair` tests for not throwing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR Reward - 50 Reward in coin(s)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants