Browse Source

add base58key tests for Address case

patch-2
Manuel Araoz 11 years ago
parent
commit
4b430be5c8
  1. 19
      test/test.misc.js
  2. 5
      test/testdata.js

19
test/test.misc.js

@ -12,6 +12,9 @@ var bignum = bitcore.bignum;
var base58 = bitcore.base58;
var base58Check = base58.base58Check;
var Address = bitcore.Address;
var networks = bitcore.networks;
describe('Miscelaneous stuff', function() {
it('should initialze the config object', function() {
should.exist(bitcore.config);
@ -63,6 +66,22 @@ describe('Miscelaneous stuff', function() {
buffertools.toHex(base58.decode(datum[1])).should.equal(datum[0]);
});
});
testdata.dataBase58KeysValid.forEach(function(datum) {
var b58 = datum[0];
var hexPayload = datum[1];
var meta = datum[2];
it('base58 keys valid ' + b58, function() {
if (meta.isPrivkey) {
(true).should.equal(true);
} else {
var a = new Address(b58);
a.isValid().should.equal(true);
a.isScript().should.equal(meta.addrType === 'script');
a.network().should.equal(meta.isTestnet?networks.testnet:networks.livenet);
}
});
});
});

5
test/testdata.js

@ -11,6 +11,8 @@ var dataUnspent = JSON.parse(fs.readFileSync('test/data/unspent.json'));
var dataUnspentSign = JSON.parse(fs.readFileSync('test/data/unspentSign.json'));
var dataSigCanonical = JSON.parse(fs.readFileSync('test/data/sig_canonical.json'));
var dataSigNonCanonical = JSON.parse(fs.readFileSync('test/data/sig_noncanonical.json'));
var dataBase58KeysValid = JSON.parse(fs.readFileSync('test/data/base58_keys_valid.json'));
var dataBase58KeysInvalid = JSON.parse(fs.readFileSync('test/data/base58_keys_invalid.json'));
module.exports.dataValid = dataValid;
module.exports.dataInvalid = dataInvalid;
@ -25,3 +27,6 @@ module.exports.dataUnspentSign = dataUnspentSign;
module.exports.dataSigCanonical = dataSigCanonical;
module.exports.dataSigNonCanonical = dataSigNonCanonical;
module.exports.dataBase58KeysValid = dataBase58KeysValid;
module.exports.dataBase58KeysInvalid = dataBase58KeysInvalid;

Loading…
Cancel
Save