Skip to content

Commit

Permalink
FABN-900 NodeSDK Connect error return URL
Browse files Browse the repository at this point in the history
Have the connect by deadline error message include
the URL address of the remote endpoint.

Change-Id: I0a3f877f87af237d7d0e60010fb9ccd77d74f9e7
Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
  • Loading branch information
harrisob committed Sep 11, 2018
1 parent 8a56714 commit 84d0718
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fabric-client/lib/Remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class Remote {
}

waitForReady(client) {
const self = this;
if (!client) {
throw new Error('Missing required gRPC client');
}
Expand All @@ -136,6 +137,9 @@ class Remote {
return new Promise((resolve, reject) => {
client.waitForReady(timeout, (err) => {
if (err) {
if(err.message) {
err.message = err.message + ' URL:'+ self.getUrl();
}
logger.error(err);

return reject(err);
Expand Down
13 changes: 12 additions & 1 deletion test/unit/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const aHost = 'atesthostname:9999';
const url = 'grpcs://' + aHost;
const aHostnameOverride = 'atesthostnameoverride';

test('\n\n ** Remote node tests **\n\n', function (t) {
test('\n\n ** Remote node tests **\n\n', async function (t) {
testutil.resetDefaults();

t.comment('\n * REMOTE *');
Expand Down Expand Up @@ -142,6 +142,17 @@ test('\n\n ** Remote node tests **\n\n', function (t) {
'Check not passing any GRPC options.'
);

peer = new Peer(url, {pem: aPem, clientKey: aPem, clientCert: aPem});
try {
await peer.sendProposal({}, 100);
} catch(error) {
if(error.toString().includes(peer.getUrl())) {
t.pass('Successfully got the waitForReady URL address error');
} else {
t.fail('Failed to get the waitForReady URL address error');
}
}

opts = { pem: aPem, 'ssl-target-name-override': aHostnameOverride };
peer = new Peer(url, opts);
t.equal(aHost, peer._endpoint.addr, 'GRPC Options tests: new Peer grpcs with opts created');
Expand Down

0 comments on commit 84d0718

Please sign in to comment.