fix formatting
This commit is contained in:
parent
e41bb599bd
commit
35e9508b28
2 changed files with 66 additions and 63 deletions
|
|
@ -181,13 +181,13 @@ Wallet.prototype._getKeyMap = function(txp) {
|
||||||
if (Object.keys(keyMap).length !== txp._inputSigners[i].length)
|
if (Object.keys(keyMap).length !== txp._inputSigners[i].length)
|
||||||
throw new Error('Signature does not match known copayers');
|
throw new Error('Signature does not match known copayers');
|
||||||
|
|
||||||
for(var j in keyMap) {
|
for (var j in keyMap) {
|
||||||
keyMapAll[j] = keyMap[j];
|
keyMapAll[j] = keyMap[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
// From here -> only to check that all inputs have the same sigs
|
// From here -> only to check that all inputs have the same sigs
|
||||||
var inSigArr = [];
|
var inSigArr = [];
|
||||||
Object.keys(keyMap).forEach(function(k){
|
Object.keys(keyMap).forEach(function(k) {
|
||||||
inSigArr.push(keyMap[k]);
|
inSigArr.push(keyMap[k]);
|
||||||
});
|
});
|
||||||
var inSig = JSON.stringify(inSigArr.sort());
|
var inSig = JSON.stringify(inSigArr.sort());
|
||||||
|
|
@ -725,7 +725,7 @@ Wallet.prototype.purgeTxProposals = function(deleteAll) {
|
||||||
this.store();
|
this.store();
|
||||||
|
|
||||||
var n = this.txProposals.length();
|
var n = this.txProposals.length();
|
||||||
return m-n;
|
return m - n;
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.reject = function(ntxid) {
|
Wallet.prototype.reject = function(ntxid) {
|
||||||
|
|
|
||||||
|
|
@ -509,9 +509,9 @@ describe('Wallet model', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var stub = sinon.stub(w.publicKeyRing,'copayersForPubkeys').returns(
|
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys').returns({
|
||||||
{'027445ab3a935dce7aee1dadb0d103ed6147a0f83deb80474a04538b2c5bc4d509':'pepe'}
|
'027445ab3a935dce7aee1dadb0d103ed6147a0f83deb80474a04538b2c5bc4d509': 'pepe'
|
||||||
);
|
});
|
||||||
w._handleTxProposal('senderID', txp, true);
|
w._handleTxProposal('senderID', txp, true);
|
||||||
Object.keys(w.txProposals.txps).length.should.equal(1);
|
Object.keys(w.txProposals.txps).length.should.equal(1);
|
||||||
w.getTxProposals().length.should.equal(1);
|
w.getTxProposals().length.should.equal(1);
|
||||||
|
|
@ -765,7 +765,7 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#createTxSync', function () {
|
describe('#createTxSync', function() {
|
||||||
it('should fail if amount below min value', function() {
|
it('should fail if amount below min value', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var utxo = createUTXO(w);
|
var utxo = createUTXO(w);
|
||||||
|
|
@ -872,9 +872,9 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
sinon.assert.callCount(updateIndex, 4);
|
sinon.assert.callCount(updateIndex, 4);
|
||||||
sinon.assert.calledWith(updateIndex, w.publicKeyRing.indexes[0] );
|
sinon.assert.calledWith(updateIndex, w.publicKeyRing.indexes[0]);
|
||||||
sinon.assert.calledWith(updateIndex, w.publicKeyRing.indexes[1] );
|
sinon.assert.calledWith(updateIndex, w.publicKeyRing.indexes[1]);
|
||||||
sinon.assert.calledWith(updateIndex, w.publicKeyRing.indexes[2] );
|
sinon.assert.calledWith(updateIndex, w.publicKeyRing.indexes[2]);
|
||||||
w.updateIndex.restore();
|
w.updateIndex.restore();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
@ -898,8 +898,8 @@ describe('Wallet model', function() {
|
||||||
index.receiveIndex.should.equal(9);
|
index.receiveIndex.should.equal(9);
|
||||||
index.changeIndex.should.equal(9);
|
index.changeIndex.should.equal(9);
|
||||||
indexDiscovery.callCount.should.equal(2);
|
indexDiscovery.callCount.should.equal(2);
|
||||||
sinon.assert.calledWith(indexDiscovery, 1, true, 2, 20 );
|
sinon.assert.calledWith(indexDiscovery, 1, true, 2, 20);
|
||||||
sinon.assert.calledWith(indexDiscovery, 2, false, 2, 20 );
|
sinon.assert.calledWith(indexDiscovery, 2, false, 2, 20);
|
||||||
w.indexDiscovery.restore();
|
w.indexDiscovery.restore();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
@ -1121,8 +1121,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('should throw if unmatched sigs', function() {
|
it('should throw if unmatched sigs', function() {
|
||||||
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
||||||
return {
|
return {};
|
||||||
};
|
|
||||||
});
|
});
|
||||||
var txp = {
|
var txp = {
|
||||||
_inputSigners: [
|
_inputSigners: [
|
||||||
|
|
@ -1138,13 +1137,12 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('should throw if unmatched sigs (case 2)', function() {
|
it('should throw if unmatched sigs (case 2)', function() {
|
||||||
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
||||||
return {
|
return {};
|
||||||
};
|
|
||||||
});
|
});
|
||||||
var txp = {
|
var txp = {
|
||||||
_inputSigners: [
|
_inputSigners: [
|
||||||
['234','321'],
|
['234', '321'],
|
||||||
['234','322']
|
['234', '322']
|
||||||
],
|
],
|
||||||
inputChainPaths: ['/m/1'],
|
inputChainPaths: ['/m/1'],
|
||||||
};
|
};
|
||||||
|
|
@ -1175,11 +1173,11 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if one inputs has missing sigs', function() {
|
it('should throw if one inputs has missing sigs', function() {
|
||||||
var call=0;
|
var call = 0;
|
||||||
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
||||||
return call++ ? {
|
return call++ ? {
|
||||||
'555': 'pepe',
|
'555': 'pepe',
|
||||||
}: {
|
} : {
|
||||||
'123': 'juan',
|
'123': 'juan',
|
||||||
'234': 'pepe',
|
'234': 'pepe',
|
||||||
};
|
};
|
||||||
|
|
@ -1199,12 +1197,12 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should throw if one inputs has different sigs', function() {
|
it('should throw if one inputs has different sigs', function() {
|
||||||
var call=0;
|
var call = 0;
|
||||||
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
||||||
return call++ ? {
|
return call++ ? {
|
||||||
'555': 'pepe',
|
'555': 'pepe',
|
||||||
'666': 'pedro',
|
'666': 'pedro',
|
||||||
}: {
|
} : {
|
||||||
'123': 'juan',
|
'123': 'juan',
|
||||||
'234': 'pepe',
|
'234': 'pepe',
|
||||||
};
|
};
|
||||||
|
|
@ -1224,12 +1222,12 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should not throw if 2 inputs has different pubs, same copayers', function() {
|
it('should not throw if 2 inputs has different pubs, same copayers', function() {
|
||||||
var call=0;
|
var call = 0;
|
||||||
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
var stub = sinon.stub(w.publicKeyRing, 'copayersForPubkeys', function() {
|
||||||
return call++ ? {
|
return call++ ? {
|
||||||
'555': 'pepe',
|
'555': 'pepe',
|
||||||
'666': 'pedro',
|
'666': 'pedro',
|
||||||
}: {
|
} : {
|
||||||
'123': 'pedro',
|
'123': 'pedro',
|
||||||
'234': 'pepe',
|
'234': 'pepe',
|
||||||
};
|
};
|
||||||
|
|
@ -1242,7 +1240,12 @@ describe('Wallet model', function() {
|
||||||
inputChainPaths: ['/m/1'],
|
inputChainPaths: ['/m/1'],
|
||||||
};
|
};
|
||||||
var gk = w._getKeyMap(txp);
|
var gk = w._getKeyMap(txp);
|
||||||
gk.should.deep.equal({ '123': 'pedro', '234': 'pepe', '555': 'pepe', '666': 'pedro' });
|
gk.should.deep.equal({
|
||||||
|
'123': 'pedro',
|
||||||
|
'234': 'pepe',
|
||||||
|
'555': 'pepe',
|
||||||
|
'666': 'pedro'
|
||||||
|
});
|
||||||
stub.restore();
|
stub.restore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue