From 84d0718ea0613eb2ed1f64aa9ac56dce44f19a55 Mon Sep 17 00:00:00 2001 From: Bret Harrison Date: Tue, 11 Sep 2018 12:43:43 -0400 Subject: [PATCH] FABN-900 NodeSDK Connect error return URL Have the connect by deadline error message include the URL address of the remote endpoint. Change-Id: I0a3f877f87af237d7d0e60010fb9ccd77d74f9e7 Signed-off-by: Bret Harrison --- fabric-client/lib/Remote.js | 4 ++++ test/unit/remote.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/fabric-client/lib/Remote.js b/fabric-client/lib/Remote.js index c15c80f327..b9c684fd24 100644 --- a/fabric-client/lib/Remote.js +++ b/fabric-client/lib/Remote.js @@ -128,6 +128,7 @@ class Remote { } waitForReady(client) { + const self = this; if (!client) { throw new Error('Missing required gRPC client'); } @@ -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); diff --git a/test/unit/remote.js b/test/unit/remote.js index ac36596560..a48a71e70e 100644 --- a/test/unit/remote.js +++ b/test/unit/remote.js @@ -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 *'); @@ -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');