Browse Source

test scan status

activeAddress
Ivan Socolsky 10 years ago
parent
commit
a643d62fb0
  1. 2
      lib/model/wallet.js
  2. 10
      test/integration/server.js

2
lib/model/wallet.js

@ -32,6 +32,7 @@ Wallet.create = function(opts) {
x.pubKey = opts.pubKey; x.pubKey = opts.pubKey;
x.network = opts.network; x.network = opts.network;
x.addressManager = AddressManager.create(); x.addressManager = AddressManager.create();
x.scanStatus = null;
return x; return x;
}; };
@ -53,6 +54,7 @@ Wallet.fromObj = function(obj) {
x.pubKey = obj.pubKey; x.pubKey = obj.pubKey;
x.network = obj.network; x.network = obj.network;
x.addressManager = AddressManager.fromObj(obj.addressManager); x.addressManager = AddressManager.fromObj(obj.addressManager);
x.scanStatus = obj.scanStatus;
return x; return x;
}; };

10
test/integration/server.js

@ -2657,7 +2657,7 @@ describe('Wallet service', function() {
NotificationBroadcaster.removeAllListeners(); NotificationBroadcaster.removeAllListeners();
}); });
it('should start an asynchronous scan', function(done) { it.only('should start an asynchronous scan', function(done) {
helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']); helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']);
var expectedPaths = [ var expectedPaths = [
'm/2147483647/0/0', 'm/2147483647/0/0',
@ -2669,6 +2669,9 @@ describe('Wallet service', function() {
]; ];
WalletService.onNotification(function(n) { WalletService.onNotification(function(n) {
if (n.type == 'ScanFinished') { if (n.type == 'ScanFinished') {
server.getWallet({}, function(err, wallet) {
should.exist(wallet.scanStatus);
wallet.scanStatus.should.equal('success');
should.not.exist(n.creatorId); should.not.exist(n.creatorId);
server.storage.fetchAddresses(wallet.id, function(err, addresses) { server.storage.fetchAddresses(wallet.id, function(err, addresses) {
should.exist(addresses); should.exist(addresses);
@ -2681,10 +2684,15 @@ describe('Wallet service', function() {
done(); done();
}); });
}) })
});
} }
}); });
server.startScan({}, function(err) { server.startScan({}, function(err) {
should.not.exist(err); should.not.exist(err);
server.getWallet({}, function(err, wallet) {
should.exist(wallet.scanStatus);
wallet.scanStatus.should.equal('running');
});
}); });
}); });
it('should start multiple asynchronous scans for different wallets', function(done) { it('should start multiple asynchronous scans for different wallets', function(done) {

Loading…
Cancel
Save