mirror of https://github.com/BTCPrivate/copay.git
fix merge with master
This commit is contained in:
parent
f4a5202a99
commit
3ce3af4408
|
@ -67,13 +67,13 @@ describe('Wallet model', function() {
|
||||||
c.network = new Network(config.network);
|
c.network = new Network(config.network);
|
||||||
c.blockchain = new Blockchain(config.blockchain);
|
c.blockchain = new Blockchain(config.blockchain);
|
||||||
|
|
||||||
c.addressBook = {
|
c.addressBook = {
|
||||||
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ' : {
|
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ': {
|
||||||
label: 'John',
|
label: 'John',
|
||||||
copayerId: '026a55261b7c898fff760ebe14fd22a71892295f3b49e0ca66727bc0a0d7f94d03',
|
copayerId: '026a55261b7c898fff760ebe14fd22a71892295f3b49e0ca66727bc0a0d7f94d03',
|
||||||
createdTs: 1403102115,
|
createdTs: 1403102115,
|
||||||
},
|
},
|
||||||
'2MtP8WyiwG7ZdVWM96CVsk2M1N8zyfiVQsY' : {
|
'2MtP8WyiwG7ZdVWM96CVsk2M1N8zyfiVQsY': {
|
||||||
label: 'Jennifer',
|
label: 'Jennifer',
|
||||||
copayerId: '032991f836543a492bd6d0bb112552bfc7c5f3b7d5388fcbcbf2fbb893b44770d7',
|
copayerId: '032991f836543a492bd6d0bb112552bfc7c5f3b7d5388fcbcbf2fbb893b44770d7',
|
||||||
createdTs: 1403103115,
|
createdTs: 1403103115,
|
||||||
|
@ -312,7 +312,7 @@ describe('Wallet model', function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
sinon.assert.callCount(spy, callCount);
|
sinon.assert.callCount(spy, callCount);
|
||||||
done();
|
done();
|
||||||
}, w.reconnectDelay*callCount*(callCount+1)/2);
|
}, w.reconnectDelay * callCount * (callCount + 1) / 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handle network indexes correctly', function() {
|
it('handle network indexes correctly', function() {
|
||||||
|
@ -616,7 +616,7 @@ describe('Wallet model', function() {
|
||||||
var ADDRESSES_RECEIVE = w.deriveAddresses(0, 20, false);
|
var ADDRESSES_RECEIVE = w.deriveAddresses(0, 20, false);
|
||||||
w.blockchain.checkActivity = function(addresses, cb) {
|
w.blockchain.checkActivity = function(addresses, cb) {
|
||||||
var activity = new Array(addresses.length);
|
var activity = new Array(addresses.length);
|
||||||
for(var i=0; i<addresses.length; i++) {
|
for (var i = 0; i < addresses.length; i++) {
|
||||||
var a1 = ADDRESSES_CHANGE.indexOf(addresses[i]);
|
var a1 = ADDRESSES_CHANGE.indexOf(addresses[i]);
|
||||||
var a2 = ADDRESSES_RECEIVE.indexOf(addresses[i]);
|
var a2 = ADDRESSES_RECEIVE.indexOf(addresses[i]);
|
||||||
activity[i] = f(Math.max(a1, a2));
|
activity[i] = f(Math.max(a1, a2));
|
||||||
|
@ -627,8 +627,10 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('#indexDiscovery should work without found activities', function(done) {
|
it('#indexDiscovery should work without found activities', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
mockFakeActivity(w, function(index) { return false });
|
mockFakeActivity(w, function(index) {
|
||||||
w.indexDiscovery(0, false, 5, function(e, lastActive){
|
return false
|
||||||
|
});
|
||||||
|
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||||
lastActive.should.equal(-1);
|
lastActive.should.equal(-1);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -636,8 +638,10 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('#indexDiscovery should continue scanning', function(done) {
|
it('#indexDiscovery should continue scanning', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
mockFakeActivity(w, function(index) { return index <= 7 });
|
mockFakeActivity(w, function(index) {
|
||||||
w.indexDiscovery(0, false, 5, function(e, lastActive){
|
return index <= 7
|
||||||
|
});
|
||||||
|
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||||
lastActive.should.equal(7);
|
lastActive.should.equal(7);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -645,8 +649,10 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('#indexDiscovery should not found beyond the scannWindow', function(done) {
|
it('#indexDiscovery should not found beyond the scannWindow', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
mockFakeActivity(w, function(index) { return index <= 10 || index == 17 });
|
mockFakeActivity(w, function(index) {
|
||||||
w.indexDiscovery(0, false, 5, function(e, lastActive){
|
return index <= 10 || index == 17
|
||||||
|
});
|
||||||
|
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||||
lastActive.should.equal(10);
|
lastActive.should.equal(10);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -654,8 +660,10 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('#indexDiscovery should look for activity along the scannWindow', function(done) {
|
it('#indexDiscovery should look for activity along the scannWindow', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
mockFakeActivity(w, function(index) { return index <= 14 && index % 2 == 0 });
|
mockFakeActivity(w, function(index) {
|
||||||
w.indexDiscovery(0, false, 5, function(e, lastActive){
|
return index <= 14 && index % 2 == 0
|
||||||
|
});
|
||||||
|
w.indexDiscovery(0, false, 5, function(e, lastActive) {
|
||||||
lastActive.should.equal(14);
|
lastActive.should.equal(14);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -663,7 +671,9 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('#updateIndexes should update correctly', function(done) {
|
it('#updateIndexes should update correctly', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
mockFakeActivity(w, function(index) { return index <= 14 && index % 2 == 0 });
|
mockFakeActivity(w, function(index) {
|
||||||
|
return index <= 14 && index % 2 == 0
|
||||||
|
});
|
||||||
w.updateIndexes(function(err) {
|
w.updateIndexes(function(err) {
|
||||||
w.publicKeyRing.indexes.receiveIndex.should.equal(15);
|
w.publicKeyRing.indexes.receiveIndex.should.equal(15);
|
||||||
w.publicKeyRing.indexes.changeIndex.should.equal(15);
|
w.publicKeyRing.indexes.changeIndex.should.equal(15);
|
||||||
|
@ -673,7 +683,9 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('#updateIndexes should store and emit event', function(done) {
|
it('#updateIndexes should store and emit event', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
mockFakeActivity(w, function(index) { return index <= 14 && index % 2 == 0 });
|
mockFakeActivity(w, function(index) {
|
||||||
|
return index <= 14 && index % 2 == 0
|
||||||
|
});
|
||||||
var spyStore = sinon.spy(w, 'store');
|
var spyStore = sinon.spy(w, 'store');
|
||||||
var spyEmit = sinon.spy(w, 'emit');
|
var spyEmit = sinon.spy(w, 'emit');
|
||||||
w.updateIndexes(function(err) {
|
w.updateIndexes(function(err) {
|
||||||
|
@ -695,16 +707,13 @@ describe('Wallet model', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
var contacts = [
|
var contacts = [{
|
||||||
{
|
label: 'Charles',
|
||||||
label: 'Charles',
|
address: '2N8pJWpXCAxmNLHKVEhz3TtTcYCtHd43xWU ',
|
||||||
address: '2N8pJWpXCAxmNLHKVEhz3TtTcYCtHd43xWU ',
|
}, {
|
||||||
},
|
label: 'Linda',
|
||||||
{
|
address: '2N4Zq92goYGrf5J4F4SZZq7jnPYbCiyRYT2 ',
|
||||||
label: 'Linda',
|
}];
|
||||||
address: '2N4Zq92goYGrf5J4F4SZZq7jnPYbCiyRYT2 ',
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
it('should create new entry for address book', function() {
|
it('should create new entry for address book', function() {
|
||||||
var w = createW();
|
var w = createW();
|
||||||
|
@ -722,7 +731,7 @@ describe('Wallet model', function() {
|
||||||
}).should.
|
}).should.
|
||||||
throw();
|
throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete an entry for address book', function() {
|
it('should delete an entry for address book', function() {
|
||||||
var w = createW();
|
var w = createW();
|
||||||
contacts.forEach(function(c) {
|
contacts.forEach(function(c) {
|
||||||
|
@ -738,8 +747,8 @@ describe('Wallet model', function() {
|
||||||
var w = createW();
|
var w = createW();
|
||||||
var data = {
|
var data = {
|
||||||
walletId: w.id,
|
walletId: w.id,
|
||||||
addressBook: {
|
addressBook: {
|
||||||
'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx' : {
|
'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx': {
|
||||||
label: 'Faucet',
|
label: 'Faucet',
|
||||||
copayerId: '026a55261b7c898fff760ebe14fd22a71892295f3b49e0ca66727bc0a0d7f94d03',
|
copayerId: '026a55261b7c898fff760ebe14fd22a71892295f3b49e0ca66727bc0a0d7f94d03',
|
||||||
createdTs: 1403102115,
|
createdTs: 1403102115,
|
||||||
|
@ -753,12 +762,6 @@ describe('Wallet model', function() {
|
||||||
data.addressBook['msj42CCGruhRsFrGATiUuh25dtxYtnpbTx'].createdTs = 1403102215;
|
data.addressBook['msj42CCGruhRsFrGATiUuh25dtxYtnpbTx'].createdTs = 1403102215;
|
||||||
w._handleAddressBook('senderID', data, true);
|
w._handleAddressBook('senderID', data, true);
|
||||||
Object.keys(w.addressBook).length.should.equal(3);
|
Object.keys(w.addressBook).length.should.equal(3);
|
||||||
w.sendTxProposal.should.throw('Illegal Argument.');
|
|
||||||
(function() {
|
|
||||||
w.sendTxProposal(ntxid)
|
|
||||||
}).should.not.throw();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#getNetworkName', function() {
|
it('#getNetworkName', function() {
|
||||||
|
|
Loading…
Reference in New Issue