From cdc80e94eb77c5654008b06512ce04ad125b702d Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 27 Nov 2014 07:35:07 -0300 Subject: [PATCH] rm senderId from setCopayers --- js/models/TxProposal.js | 7 ++++--- js/models/Wallet.js | 2 +- test/TxProposal.js | 16 ++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/js/models/TxProposal.js b/js/models/TxProposal.js index e1b6679c0..865d70dd1 100644 --- a/js/models/TxProposal.js +++ b/js/models/TxProposal.js @@ -404,7 +404,7 @@ TxProposal.prototype.getSent = function() { return this.sentTs; } -TxProposal.prototype.setCopayers = function(senderId, keyMap) { +TxProposal.prototype.setCopayers = function(pubkeyToCopayerMap) { var newCopayer = {}, oldCopayers = {}, newSignedBy = {}, @@ -431,7 +431,7 @@ TxProposal.prototype.setCopayers = function(senderId, keyMap) { var iSig = this.getSignersPubKeys(); for (var i in iSig) { - var copayerId = keyMap[iSig[i]]; + var copayerId = pubkeyToCopayerMap[iSig[i]]; if (!copayerId) throw new Error('Found unknown signature') @@ -448,7 +448,8 @@ TxProposal.prototype.setCopayers = function(senderId, keyMap) { throw new Error('New TX must have only 1 new signature'); // Handler creator / createdTs. - // from senderId, and must be signed by senderId + // from senderId, and must be signed by senderId * DISABLED* + // if (isNew) { this.creator = Object.keys(newCopayer)[0]; this.seenBy[this.creator] = this.createdTs = Date.now(); diff --git a/js/models/Wallet.js b/js/models/Wallet.js index 7db731745..4907d56fe 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -520,7 +520,7 @@ Wallet.prototype._onTxProposal = function(senderId, data) { } var keyMap = self._getPubkeyToCopayerMap(incomingTx); - incomingTx.setCopayers(senderId, keyMap); + incomingTx.setCopayers(keyMap); self.txProposals.add(incomingTx); self.emitAndKeepAlive('txProposalEvent', { diff --git a/test/TxProposal.js b/test/TxProposal.js index 76ed3c7b5..6e38d6d3d 100644 --- a/test/TxProposal.js +++ b/test/TxProposal.js @@ -480,7 +480,7 @@ describe('TxProposal', function() { }; delete txp['creator']; (function() { - txp.setCopayers('juan', { + txp.setCopayers({ pk1: 'pepe' }) }).should.throw('no creator'); @@ -495,7 +495,7 @@ describe('TxProposal', function() { ['pkX'] ]; (function() { - txp.setCopayers('juan', { + txp.setCopayers({ pk1: 'pepe' }) }).should.throw('creator'); @@ -512,7 +512,7 @@ describe('TxProposal', function() { ['pk0', 'pkX'] ]; (function() { - txp.setCopayers('juan', { + txp.setCopayers({ pk1: 'pepe' }) }).should.throw('unknown sig'); @@ -529,7 +529,7 @@ describe('TxProposal', function() { 'creator': Date.now() }; (function() { - txp.setCopayers('juan', { + txp.setCopayers({ pk0: 'creator', pk1: 'pepe', pk2: 'john' @@ -546,7 +546,7 @@ describe('TxProposal', function() { txp.signedBy = { 'creator': Date.now() }; - txp.setCopayers('pepe', { + txp.setCopayers({ pk0: 'creator', pk1: 'pepe', pk2: 'john' @@ -562,7 +562,7 @@ describe('TxProposal', function() { txp.signedBy = {}; delete txp['creator']; delete txp['creatorTs']; - txp.setCopayers('creator', { + txp.setCopayers({ pk0: 'creator', pk1: 'pepe', pk2: 'john' @@ -581,7 +581,7 @@ describe('TxProposal', function() { sinon.stub(txp,'getSignersPubKeys').returns(['pk0', 'pk1']); (function() { txp.setCopayers( - 'creator', { + { pk0: 'creator', pk1: 'pepe', pk2: 'john' @@ -600,7 +600,7 @@ describe('TxProposal', function() { txp.signedBy = { 'creator': 1 }; - txp.setCopayers('pepe', { + txp.setCopayers({ pk0: 'creator', pk1: 'pepe', pk2: 'john'