Skip to content

Commit

Permalink
added main logic for the new peer-gateaway connector including unit t…
Browse files Browse the repository at this point in the history
…ests (#1270)

+ added minor changes to the connectionProfileDefinition

Signed-off-by: fraVlaca <ocsenarf@outlook.com>
  • Loading branch information
fraVlaca committed Apr 1, 2022
1 parent ada19c3 commit a372f18
Show file tree
Hide file tree
Showing 7 changed files with 1,368 additions and 29 deletions.
Expand Up @@ -201,21 +201,26 @@ class ConnectionProfileDefinition {
if (!this.connectionProfile.organizations) {
throw new Error('No organizations property can be found for the connection profile provided');
}
let peers;

for (const org in this.connectionProfile.organizations) {
if (this.connectionProfile.organizations[org].mspid === mspid) {
if(!this.connectionProfile.organizations[org].peers) {
throw new Error(`Org with mspid "${mspid}" listed in connectionProfile.organizations does not have any peers property`);
const peers = this.connectionProfile.organizations[org].peers;

if (!peers) {
throw new Error(`Org with mspid ${mspid} listed in connectionProfile.organizations does not have any peers property`);
}
peers = this.connectionProfile.organizations[org].peers;
if (peers.length === 0) {
throw new Error(`Org with mspid ${mspid} has a peers property but it is empty`);
}

return peers;
}
}
if (!peers) {
throw new Error(`Org with mspid ${mspid} cannot be found in connectionProfile.organizations`);
}
return peers;

throw new Error(`Org with mspid ${mspid} cannot be found in connectionProfile.organizations`);
}


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

0 comments on commit a372f18

Please sign in to comment.