diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-05-20 03:06:45 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-05-20 03:06:45 +0800 |
commit | c8deb355f7d1e4d1e10868a7d960fa460a7c51db (patch) | |
tree | 7f00234f62abda988035dc4ac83f7981ad446452 /test | |
parent | 685a1881b86c19fe52a7cd82ed4e2b34617429ff (diff) | |
download | tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.tar tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.tar.gz tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.tar.bz2 tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.tar.lz tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.tar.xz tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.tar.zst tangerine-wallet-browser-c8deb355f7d1e4d1e10868a7d960fa460a7c51db.zip |
Add address capitalization checksumming
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/util_test.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/unit/util_test.js b/test/unit/util_test.js index 3f46d4e9b..020fad783 100644 --- a/test/unit/util_test.js +++ b/test/unit/util_test.js @@ -17,6 +17,52 @@ describe('util', function() { this.sinon.restore() }) + describe('addressSummary', function() { + it('should add case-sensitive checksum', function() { + var address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825' + var result = util.addressSummary(address) + assert.equal(result, '0xFDEa65C8...b825') + }) + }) + + describe('isValidAddress', function() { + it('should allow 40-char non-prefixed hex', function() { + var address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b825' + var result = util.isValidAddress(address) + assert.ok(result) + }) + + it('should allow 42-char non-prefixed hex', function() { + var address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825' + var result = util.isValidAddress(address) + assert.ok(result) + }) + + it('should not allow less non hex-prefixed', function() { + var address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b85' + var result = util.isValidAddress(address) + assert.ok(!result) + }) + + it('should not allow less hex-prefixed', function() { + var address = '0xfdea65ce26263f6d9a1b5de9555d2931a33b85' + var result = util.isValidAddress(address) + assert.ok(!result) + }) + + it('should recognize correct capitalized checksum', function() { + var address = '0xFDEa65C8e26263F6d9A1B5de9555D2931A33b825' + var result = util.isValidAddress(address) + assert.ok(result) + }) + + it('should recognize incorrect capitalized checksum', function() { + var address = '0xFDea65C8e26263F6d9A1B5de9555D2931A33b825' + var result = util.isValidAddress(address) + assert.ok(!result) + }) + }) + describe('numericBalance', function() { it('should return a BN 0 if given nothing', function() { |