Browse Source

test scan status

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

2
lib/model/wallet.js

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

34
test/integration/server.js

@ -2657,7 +2657,7 @@ describe('Wallet service', function() {
NotificationBroadcaster.removeAllListeners();
});
it('should start an asynchronous scan', function(done) {
it.only('should start an asynchronous scan', function(done) {
helpers.stubAddressActivity(['3K2VWMXheGZ4qG35DyGjA2dLeKfaSr534A']);
var expectedPaths = [
'm/2147483647/0/0',
@ -2669,22 +2669,30 @@ describe('Wallet service', function() {
];
WalletService.onNotification(function(n) {
if (n.type == 'ScanFinished') {
should.not.exist(n.creatorId);
server.storage.fetchAddresses(wallet.id, function(err, addresses) {
should.exist(addresses);
addresses.length.should.equal(expectedPaths.length);
var paths = _.pluck(addresses, 'path');
_.difference(paths, expectedPaths).length.should.equal(0);
server.createAddress({}, function(err, address) {
should.not.exist(err);
address.path.should.equal('m/2147483647/0/4');
done();
});
})
server.getWallet({}, function(err, wallet) {
should.exist(wallet.scanStatus);
wallet.scanStatus.should.equal('success');
should.not.exist(n.creatorId);
server.storage.fetchAddresses(wallet.id, function(err, addresses) {
should.exist(addresses);
addresses.length.should.equal(expectedPaths.length);
var paths = _.pluck(addresses, 'path');
_.difference(paths, expectedPaths).length.should.equal(0);
server.createAddress({}, function(err, address) {
should.not.exist(err);
address.path.should.equal('m/2147483647/0/4');
done();
});
})
});
}
});
server.startScan({}, function(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) {

Loading…
Cancel
Save