Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit c0dc70e

Browse files
Correctly handle error when no committers are specified (#568) (#569)
Signed-off-by: sapthasurendran <[email protected]> (cherry picked from commit 8cfd49d) Co-authored-by: sapthasurendran <[email protected]>
1 parent 70d39f7 commit c0dc70e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

fabric-common/lib/Commit.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ class Commit extends Proposal {
182182
} else if (targets) {
183183
logger.debug('%s - sending to the targets', method);
184184
const committers = this.channel.getTargetCommitters(targets);
185+
186+
if (committers.length === 0) {
187+
throw new Error('Unable to find any target committers');
188+
}
189+
185190
let result;
186191
for (const committer of committers) {
187192
const isConnected = await committer.checkConnection();

fabric-common/test/Commit.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ describe('Commit', () => {
106106
});
107107

108108
describe('#send', () => {
109+
it('throws if targets committers is missing', async () => {
110+
commit.build(idx);
111+
const request = {
112+
targets: []
113+
};
114+
await commit.sign(idx);
115+
await commit.send(request).should.be.rejectedWith('Unable to find any target committers');
116+
});
109117
it('throws if targets is missing', async () => {
110118
endorsement._proposalResponses = [];
111119
endorsement._proposalResponses.push(proposalResponse);

0 commit comments

Comments
 (0)