ethers.js/tests/test-checksum-address.js
2016-08-01 18:34:12 -04:00

28 lines
693 B
JavaScript

'use strict';
var Wallet = require('../index.js');
var ethereumUtil = require('ethereumjs-util');
var utils = require('./utils.js');
module.exports = function(test) {
function testAddress(address) {
var official = ethereumUtil.toChecksumAddress(address);
var ethers = Wallet.getAddress(address);
test.equal(ethers, official, 'wrong address');
}
test.expect(2 + 10000);
testAddress('0x0000000000000000000000000000000000000000');
testAddress('0xffffffffffffffffffffffffffffffffffffffff');
for (var i = 0; i < 10000; i++) {
testAddress(utils.randomHexString(20));
}
test.done();
};
module.exports.testSelf = module.exports;