olalonde
11 years ago
2 changed files with 101 additions and 0 deletions
@ -0,0 +1,92 @@ |
|||
'use strict'; |
|||
|
|||
var chai = chai || require('chai'); |
|||
var bitcore = bitcore || require('../bitcore'); |
|||
|
|||
var should = chai.should(); |
|||
|
|||
var Armory = bitcore.Armory; |
|||
var Address = bitcore.Address; |
|||
|
|||
/** |
|||
* This is the Armory root code that was used to generated the hard coded values in |
|||
* those tests: |
|||
*/ |
|||
|
|||
var seed = [ |
|||
'aagh hjfj sihk ietj giik wwai awtd uodh hnji', |
|||
'soss uaku egod utai itos fijj ihgi jhau jtoo' |
|||
].join('\n'); |
|||
|
|||
/* |
|||
* It was retrieved by creating a wallet in Armory and creating a paper backup. |
|||
* |
|||
* This is the public key as presented on the generated Armory paper wallets: |
|||
*/ |
|||
|
|||
var PublicX = '9df5 23e7 18b9 1f59 a790 2d46 999f 9357 ccf8 7208 24d4 3076 4516 b809 f7ab ce4e'; |
|||
var PublicY = '66ba 5d21 4682 0dae 401d 9506 8437 2516 79f9 0c56 4186 cc50 07df c6d0 6989 1ff4'; |
|||
var pubkey = '04' + PublicX.split(' ').join('') + PublicY.split(' ').join(''); |
|||
|
|||
/* |
|||
* This chain code was derived from the seed above: |
|||
*/ |
|||
var chaincode = '84ac14bc4b388b33da099a0b4ee3b507284d99e1476639e36e5ca5e6af86481e'; |
|||
|
|||
/* |
|||
* This is some addresses generated from the wallet: |
|||
*/ |
|||
var address = [ |
|||
'1PUzLkds8eHGjHPaW7v7h23bzmHjrRMVqz', |
|||
'1CGrip2uQUwhP2f3ARfbcrmtdwvWzELRmj', |
|||
'1BfBauMP4PX1ZBYrqH4K4R8KWrFfskrs7E', |
|||
'15emDCBVgBJLDP5cKxuwZ4Q77sfqEcwZvC', |
|||
'16tDJhMYBv1szZgRZCohWrzEvzX2bG7vEQ' |
|||
]; |
|||
|
|||
var instance, fromseed, first; |
|||
|
|||
describe('Armory', function() { |
|||
it('should initialze the main object', function() { |
|||
should.exist(Armory); |
|||
}); |
|||
|
|||
it('should be able to create instance from chaincode, pubkey', function() { |
|||
instance = new Armory(chaincode, pubkey); |
|||
should.exist(instance); |
|||
}); |
|||
|
|||
it('should be able to create instance from seed', function() { |
|||
fromseed = Armory.fromSeed(seed); |
|||
should.exist(fromseed); |
|||
}); |
|||
|
|||
it('fromseed should generate the expected chain code', function() { |
|||
should.equal(fromseed.chaincode.toString('hex'), chaincode.toString('hex')); |
|||
should.equal(fromseed.chaincode.toString('hex'), instance.chaincode.toString('hex')); |
|||
}); |
|||
|
|||
it('fromseed should be able to generate the first public key', function() { |
|||
first = fromseed.next(); |
|||
should.exist(first); |
|||
}); |
|||
|
|||
it('instance created from chaincode,pubkey and the first instance generated by fromseed should match', function() { |
|||
should.equal(first.pubkey.toString('hex'), instance.pubkey.toString('hex')); |
|||
should.equal(first.chaincode.toString('hex'), instance.chaincode.toString('hex')); |
|||
}); |
|||
|
|||
it('armory should generate the expected addresses for the given chaincode,pubkey', function() { |
|||
var addr, a; |
|||
a = instance; |
|||
for (var i = 0; i < address.length; i++) { |
|||
should.equal(Address.fromPubKey(a.pubkey).as('base58'), address[i]); |
|||
a = a.next(); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
|
Loading…
Reference in new issue