test wallet recreation

This commit is contained in:
Ivan Socolsky 2015-04-01 17:11:39 -03:00
parent ed43742189
commit cdd1e9ea58
1 changed files with 50 additions and 1 deletions

View File

@ -2481,7 +2481,13 @@ describe('Wallet service', function() {
});
describe('#scan', function() {
WalletService.scanConfig.SCAN_WINDOW = 2;
var scanWindowOld = WalletService.scanConfig.SCAN_WINDOW;
beforeEach(function() {
WalletService.scanConfig.SCAN_WINDOW = 2;
});
afterEach(function() {
WalletService.scanConfig.SCAN_WINDOW = scanWindowOld;
});
it('should scan main addresses', function(done) {
helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']);
@ -2539,6 +2545,49 @@ describe('Wallet service', function() {
});
});
});
it('should restore wallet balance', function(done) {
async.waterfall([
function(next) {
helpers.createAndJoinWallet(1, 2, function(server, wallet) {
helpers.stubUtxos(server, wallet, [1, 2, 3], function(utxos) {
should.exist(utxos);
helpers.stubAddressActivity(_.pluck(utxos, 'address'));
server.getBalance({}, function(err, balance) {
balance.totalAmount.should.equal(helpers.toSatoshi(6));
next(null, server, wallet);
});
});
});
},
function(server, wallet, next) {
server.removeWallet({}, function(err) {
next(err);
});
},
function(next) {
// NOTE: this works because it creates the exact same wallet!
helpers.createAndJoinWallet(1, 2, function(server, wallet) {
server.getBalance({}, function(err, balance) {
balance.totalAmount.should.equal(0);
next(null, server, wallet);
});
});
},
function(server, wallet, next) {
server.scan({}, function(err) {
should.not.exist(err);
server.getBalance(wallet.id, function(err, balance) {
balance.totalAmount.should.equal(helpers.toSatoshi(6));
next();
})
});
},
], function(err) {
should.not.exist(err);
done();
});
});
});
});