HomePhabricator

[Cashtab] Improve isAliasFormat function and add unit tests

Description

[Cashtab] Improve isAliasFormat function and add unit tests

Summary:
Alias validation evolved incrementally with the alias spec. This has left overcomplicated validation functions and some missed validation cases.

Fix this.

Function one: meetsAliasSpec

Does a given string meet the spec for registration as an alias?

Function two: isValidAliasSendInput -- same as function one, except it must also end with a .xec suffix.

Add unit tests for both cases. Since these functions are already used in the app, implement the new functions.

Test Plan:
npm test

grep -r isAliasFormat src/ and no output

Edit config/alias.js to set aliasEnabled to true

npm start

Navigate to alias screen and test

  • valid alias input
  • non-alphanumeric alias input
  • valid characters but too many bytes alias input

and verify correct error msgs are displayed

Verify that attempting to enter a valid alias with '.xec' suffix does not pass validation

Navigate to Send, SendToken screens and test

  • valid alias input with .xec suffix
  • invalid address gives error 'invalid address'
  • invalid alias gives error 'invalid address' (note: we will add better error msgs here in the parseAddressForParams upgrade

Navigate to SignVerifyMsg screen

  • valid alias input gives error aliases not supported for signature verifications
  • Invalid input (alias or addr) gives 'invalid xec address' error

Reviewers: #bitcoin_abc, emack

Reviewed By: #bitcoin_abc, emack

Subscribers: emack

Differential Revision: https://reviews.bitcoinabc.org/D15155

Details

Provenance
bytesofmanAuthored on Jan 12 2024, 21:11
bytesofmanPushed on Jan 16 2024, 14:08
Reviewer
Restricted Project
Differential Revision
D15155: [Cashtab] Improve isAliasFormat function and add unit tests
Parents
rABCfb3cb52b176f: [Chronik] Plugins: Add `__init__`, `__eq__` and `__repr__` methods
Branches
Unknown
Tags
Unknown