Skip to content

Commit a372f18

Browse files
authored
added main logic for the new peer-gateaway connector including unit tests (#1270)
+ added minor changes to the connectionProfileDefinition Signed-off-by: fraVlaca <ocsenarf@outlook.com>
1 parent ada19c3 commit a372f18

File tree

7 files changed

+1368
-29
lines changed

7 files changed

+1368
-29
lines changed

packages/caliper-fabric/lib/connector-configuration/ConnectionProfileDefinition.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,26 @@ class ConnectionProfileDefinition {
201201
if (!this.connectionProfile.organizations) {
202202
throw new Error('No organizations property can be found for the connection profile provided');
203203
}
204-
let peers;
204+
205205
for (const org in this.connectionProfile.organizations) {
206206
if (this.connectionProfile.organizations[org].mspid === mspid) {
207-
if(!this.connectionProfile.organizations[org].peers) {
208-
throw new Error(`Org with mspid "${mspid}" listed in connectionProfile.organizations does not have any peers property`);
207+
const peers = this.connectionProfile.organizations[org].peers;
208+
209+
if (!peers) {
210+
throw new Error(`Org with mspid ${mspid} listed in connectionProfile.organizations does not have any peers property`);
209211
}
210-
peers = this.connectionProfile.organizations[org].peers;
212+
if (peers.length === 0) {
213+
throw new Error(`Org with mspid ${mspid} has a peers property but it is empty`);
214+
}
215+
216+
return peers;
211217
}
212218
}
213-
if (!peers) {
214-
throw new Error(`Org with mspid ${mspid} cannot be found in connectionProfile.organizations`);
215-
}
216-
return peers;
219+
220+
throw new Error(`Org with mspid ${mspid} cannot be found in connectionProfile.organizations`);
217221
}
218222

223+
219224
/**
220225
* Return the tls certificate for the specified peer, can only be called when a grps url and respective certs are provided
221226
* @param {string} peer the name of the peer

0 commit comments

Comments
 (0)