check for scan error

This commit is contained in:
Ivan Socolsky 2015-04-14 15:45:52 -03:00
parent 3678b27bf5
commit 8a73672398
2 changed files with 18 additions and 2 deletions

View File

@ -1224,7 +1224,7 @@ WalletService.prototype.scan = function(opts, cb) {
WalletService.prototype.startScan = function(opts, cb) {
var self = this;
function scanFinished(wallet, err) {
function scanFinished(err) {
var result = err ? 'error' : 'success';
var data = {
result: result,
@ -1247,7 +1247,7 @@ WalletService.prototype.startScan = function(opts, cb) {
if (err) return cb(err);
setTimeout(function() {
self.scan(opts, _.bind(scanFinished, self, wallet));
self.scan(opts, scanFinished);
}, 100);
return cb(null, {

View File

@ -2695,6 +2695,22 @@ describe('Wallet service', function() {
});
});
});
it('should set scan status error when unable to reach blockchain', function(done) {
blockchainExplorer.getAddressActivity = sinon.stub().yields('dummy error');
WalletService.onNotification(function(n) {
if (n.type == 'ScanFinished') {
should.exist(n.data.error);
server.getWallet({}, function(err, wallet) {
should.exist(wallet.scanStatus);
wallet.scanStatus.should.equal('error');
done();
});
}
});
server.startScan({}, function(err) {
should.not.exist(err);
});
});
it('should start multiple asynchronous scans for different wallets', function(done) {
helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']);
WalletService.scanConfig.SCAN_WINDOW = 1;