diff --git a/fabric-client/lib/Channel.js b/fabric-client/lib/Channel.js index 64c20fd5b8..16d05f38d5 100755 --- a/fabric-client/lib/Channel.js +++ b/fabric-client/lib/Channel.js @@ -3313,6 +3313,9 @@ const Channel = class { if (!proposal_response) { throw new Error('Missing proposal response'); } + if (proposal_response instanceof Error) { + return false; + } if (!proposal_response.endorsement) { throw new Error('Parameter must be a ProposalResponse Object'); } @@ -3382,6 +3385,10 @@ const Channel = class { throw new Error('proposal_responses is empty'); } + if (proposal_responses.some((response) => response instanceof Error)) { + return false; + } + const first_one = _getProposalResponseResults(proposal_responses[0]); for (let i = 1; i < proposal_responses.length; i++) { const next_one = _getProposalResponseResults(proposal_responses[i]); diff --git a/fabric-client/test/Channel.js b/fabric-client/test/Channel.js index 57dc9c7fa5..2fd19f147a 100644 --- a/fabric-client/test/Channel.js +++ b/fabric-client/test/Channel.js @@ -618,6 +618,13 @@ describe('Channel', () => { const result = channel.compareProposalResponseResults([proposalResponse1, proposalResponse2]); expect(result).to.be.false; }); + + it('returns false if any proposal responses are Error objects', () => { + const proposalResponse1 = createProposalResponse('foo'); + const proposalResponse2 = new Error('bah'); + const result = channel.compareProposalResponseResults([proposalResponse1, proposalResponse2]); + expect(result).to.be.false; + }); }); describe('#generateUnsignedProposal', () => { @@ -760,6 +767,12 @@ describe('Channel', () => { const result = channel.verifyProposalResponse(proposalResponse); expect(result).to.be.true; }); + + it('returns false if the proposal response is an error', () => { + const proposalResponse = new Error('sadface'); + const result = channel.verifyProposalResponse(proposalResponse); + expect(result).to.be.false; + }); }); describe('#generateUnsignedTransaction', () => {