mirror of https://github.com/BTCPrivate/copay.git
performance improvement
This commit is contained in:
parent
7e3477d03f
commit
e95bb8e580
|
@ -331,6 +331,7 @@ describe('Wallet model', function() {
|
|||
var w = cachedCreateW2();
|
||||
var spy = sinon.spy(w, 'scheduleConnect');
|
||||
var callCount = 3;
|
||||
w.reconnectDelay = 25;
|
||||
w.netStart();
|
||||
setTimeout(function() {
|
||||
sinon.assert.callCount(spy, callCount);
|
||||
|
@ -660,9 +661,17 @@ describe('Wallet model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
var mockFakeActivity = function(w, f) {
|
||||
var ADDRESSES_CHANGE = w.deriveAddresses(0, 20, true);
|
||||
var ADDRESSES_RECEIVE = w.deriveAddresses(0, 20, false);
|
||||
|
||||
describe('#indexDiscovery', function() {
|
||||
var ADDRESSES_CHANGE, ADDRESSES_RECEIVE, w;
|
||||
|
||||
before(function() {
|
||||
w = cachedCreateW2();
|
||||
ADDRESSES_CHANGE = w.deriveAddresses(0, 20, true);
|
||||
ADDRESSES_RECEIVE = w.deriveAddresses(0, 20, false);
|
||||
});
|
||||
|
||||
var mockFakeActivity = function(f) {
|
||||
w.blockchain.checkActivity = function(addresses, cb) {
|
||||
var activity = new Array(addresses.length);
|
||||
for (var i = 0; i < addresses.length; i++) {
|
||||
|
@ -675,9 +684,8 @@ describe('Wallet model', function() {
|
|||
}
|
||||
|
||||
it('#indexDiscovery should work without found activities', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
mockFakeActivity(w, function(index) {
|
||||
return false
|
||||
mockFakeActivity(function(index) {
|
||||
return false;
|
||||
});
|
||||
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||
lastActive.should.equal(-1);
|
||||
|
@ -686,9 +694,8 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('#indexDiscovery should continue scanning', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
mockFakeActivity(w, function(index) {
|
||||
return index <= 7
|
||||
mockFakeActivity(function(index) {
|
||||
return index <= 7;
|
||||
});
|
||||
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||
lastActive.should.equal(7);
|
||||
|
@ -697,9 +704,8 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('#indexDiscovery should not found beyond the scannWindow', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
mockFakeActivity(w, function(index) {
|
||||
return index <= 10 || index == 17
|
||||
mockFakeActivity(function(index) {
|
||||
return index <= 10 || index == 17;
|
||||
});
|
||||
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||
lastActive.should.equal(10);
|
||||
|
@ -708,9 +714,8 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('#indexDiscovery should look for activity along the scannWindow', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
mockFakeActivity(w, function(index) {
|
||||
return index <= 14 && index % 2 == 0
|
||||
mockFakeActivity(function(index) {
|
||||
return index <= 14 && index % 2 == 0;
|
||||
});
|
||||
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||
lastActive.should.equal(14);
|
||||
|
@ -719,10 +724,10 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('#updateIndexes should update correctly', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
mockFakeActivity(w, function(index) {
|
||||
return index <= 14 && index % 2 == 0
|
||||
mockFakeActivity(function(index) {
|
||||
return index <= 14 && index % 2 == 0;
|
||||
});
|
||||
|
||||
w.updateIndexes(function(err) {
|
||||
w.publicKeyRing.indexes.receiveIndex.should.equal(15);
|
||||
w.publicKeyRing.indexes.changeIndex.should.equal(15);
|
||||
|
@ -731,9 +736,8 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('#updateIndexes should store and emit event', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
mockFakeActivity(w, function(index) {
|
||||
return index <= 14 && index % 2 == 0
|
||||
mockFakeActivity(function(index) {
|
||||
return index <= 14 && index % 2 == 0;
|
||||
});
|
||||
var spyStore = sinon.spy(w, 'store');
|
||||
var spyEmit = sinon.spy(w, 'emit');
|
||||
|
@ -744,6 +748,8 @@ describe('Wallet model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('#deriveAddresses', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
var addresses1 = w.deriveAddresses(0, 5, false);
|
||||
|
|
Loading…
Reference in New Issue