2017-10-19 04:28:45 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
var utils = require('./utils');
|
2018-07-23 10:02:39 +03:00
|
|
|
var ethers = utils.getEthers(__filename);
|
2017-10-19 04:28:45 +03:00
|
|
|
|
|
|
|
describe('Private key generation', function() {
|
|
|
|
var tests = utils.loadTests('accounts');
|
|
|
|
tests.forEach(function(test) {
|
|
|
|
if (!test.privateKey) { return; }
|
|
|
|
it(('correctly converts private key - ' + test.name), function() {
|
2018-03-05 03:31:09 +03:00
|
|
|
var wallet = new ethers.Wallet(test.privateKey);
|
2017-10-19 04:28:45 +03:00
|
|
|
assert.equal(wallet.address.toLowerCase(), test.address.toLowerCase(),
|
|
|
|
'correctly computes privateKey - ' + test.privateKey);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Checksum and ICAP address generation', function() {
|
|
|
|
var tests = utils.loadTests('accounts');
|
|
|
|
tests.forEach(function(test) {
|
|
|
|
it(('correctly transforms address - ' + test.name), function() {
|
2018-03-05 03:31:09 +03:00
|
|
|
assert.equal(ethers.utils.getAddress(test.address), test.checksumAddress,
|
2017-10-19 04:28:45 +03:00
|
|
|
'correctly computes checksum address from address');
|
2018-06-17 23:32:57 +03:00
|
|
|
assert.equal(ethers.utils.getIcapAddress(test.address), test.icapAddress,
|
2017-10-19 04:28:45 +03:00
|
|
|
'correctly computes ICAP address from address');
|
2018-03-05 03:31:09 +03:00
|
|
|
assert.equal(ethers.utils.getAddress(test.checksumAddress), test.checksumAddress,
|
2017-10-19 04:28:45 +03:00
|
|
|
'correctly computes checksum address from checksum address');
|
2018-06-17 23:32:57 +03:00
|
|
|
assert.equal(ethers.utils.getIcapAddress(test.checksumAddress), test.icapAddress,
|
2017-10-19 04:28:45 +03:00
|
|
|
'correctly computes ICAP address from checksum address');
|
2018-03-05 03:31:09 +03:00
|
|
|
assert.equal(ethers.utils.getAddress(test.icapAddress), test.checksumAddress,
|
2017-10-19 04:28:45 +03:00
|
|
|
'correctly computes checksum address from icap address');
|
2018-06-17 23:32:57 +03:00
|
|
|
assert.equal(ethers.utils.getIcapAddress(test.icapAddress), test.icapAddress,
|
2017-10-19 04:28:45 +03:00
|
|
|
'correctly computes ICAP address from icap address');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|