|
|
@ -1222,6 +1222,7 @@ describe('Wallet service', function() { |
|
|
|
address.network.should.equal('livenet'); |
|
|
|
address.address.should.equal('36q2G5FMGvJbPgAVEaiyAsFGmpkhPKwk2r'); |
|
|
|
address.isChange.should.be.false; |
|
|
|
address.coin.should.equal('btc'); |
|
|
|
address.path.should.equal('m/0/0'); |
|
|
|
address.type.should.equal('P2SH'); |
|
|
|
server.getNotifications({}, function(err, notifications) { |
|
|
@ -1271,6 +1272,76 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('shared wallets (BIP44/BCH)', function() { |
|
|
|
beforeEach(function(done) { |
|
|
|
helpers.createAndJoinWallet(2, 2, { |
|
|
|
coin: 'bch' |
|
|
|
}, function(s, w) { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should create address', function(done) { |
|
|
|
server.createAddress({}, function(err, address) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(address); |
|
|
|
address.walletId.should.equal(wallet.id); |
|
|
|
address.network.should.equal('livenet'); |
|
|
|
address.address.should.equal('HBf8isgS8EXG1r3X6GP89FmooUmiJ42wHS'); |
|
|
|
address.isChange.should.be.false; |
|
|
|
address.path.should.equal('m/0/0'); |
|
|
|
address.type.should.equal('P2SH'); |
|
|
|
address.coin.should.equal('bch'); |
|
|
|
server.getNotifications({}, function(err, notifications) { |
|
|
|
should.not.exist(err); |
|
|
|
var notif = _.find(notifications, { |
|
|
|
type: 'NewAddress' |
|
|
|
}); |
|
|
|
should.exist(notif); |
|
|
|
notif.data.address.should.equal(address.address); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should create many addresses on simultaneous requests', function(done) { |
|
|
|
var N = 5; |
|
|
|
async.mapSeries(_.range(N), function(i, cb) { |
|
|
|
server.createAddress({}, cb); |
|
|
|
}, function(err, addresses) { |
|
|
|
addresses.length.should.equal(N); |
|
|
|
_.each(_.range(N), function(i) { |
|
|
|
addresses[i].path.should.equal('m/0/' + i); |
|
|
|
}); |
|
|
|
// No two identical addresses
|
|
|
|
_.uniq(_.pluck(addresses, 'address')).length.should.equal(N); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should not create address if unable to store it', function(done) { |
|
|
|
sinon.stub(server.storage, 'storeAddressAndWallet').yields('dummy error'); |
|
|
|
server.createAddress({}, function(err, address) { |
|
|
|
should.exist(err); |
|
|
|
should.not.exist(address); |
|
|
|
|
|
|
|
server.getMainAddresses({}, function(err, addresses) { |
|
|
|
addresses.length.should.equal(0); |
|
|
|
|
|
|
|
server.storage.storeAddressAndWallet.restore(); |
|
|
|
server.createAddress({}, function(err, address) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(address); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('1-of-1 (BIP44 & P2PKH)', function() { |
|
|
|
beforeEach(function(done) { |
|
|
|
helpers.createAndJoinWallet(1, 1, function(s, w) { |
|
|
@ -7672,7 +7743,7 @@ describe('Wallet service', function() { |
|
|
|
address.walletId.should.equal(wallet.bch.id); |
|
|
|
address.coin.should.equal('bch'); |
|
|
|
address.network.should.equal('livenet'); |
|
|
|
address.address.should.equal('1L3z9LPd861FWQhf3vDn89Fnc9dkdBo2CG'); |
|
|
|
address.address.should.equal('CbWsiNjh18ynQYc5jfYhhespEGrAaW8YUq'); |
|
|
|
server.btc.getMainAddresses({}, function(err, addresses) { |
|
|
|
should.not.exist(err); |
|
|
|
addresses.length.should.equal(1); |
|
|
@ -7684,7 +7755,7 @@ describe('Wallet service', function() { |
|
|
|
addresses.length.should.equal(1); |
|
|
|
addresses[0].coin.should.equal('bch'); |
|
|
|
addresses[0].walletId.should.equal(wallet.bch.id); |
|
|
|
addresses[0].address.should.equal('1L3z9LPd861FWQhf3vDn89Fnc9dkdBo2CG'); |
|
|
|
addresses[0].address.should.equal('CbWsiNjh18ynQYc5jfYhhespEGrAaW8YUq'); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|