Skip to content

Commit

Permalink
fix ping to throw (#1426)
Browse files Browse the repository at this point in the history
Signed-off-by: ochikov <[email protected]>
  • Loading branch information
ochikov authored Jan 31, 2023
1 parent 48b6625 commit 2720c7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,17 +637,13 @@ export default class Client {
* @param {AccountId | string} accountId
*/
async ping(accountId) {
try {
await new AccountBalanceQuery({ accountId })
.setNodeAccountIds([
accountId instanceof AccountId
? accountId
: AccountId.fromString(accountId),
])
.execute(this);
} catch (_) {
// Do nothing
}
await new AccountBalanceQuery({ accountId })
.setNodeAccountIds([
accountId instanceof AccountId
? accountId
: AccountId.fromString(accountId),
])
.execute(this);
}

async pingAll() {
Expand Down
12 changes: 12 additions & 0 deletions test/integration/ClientIntegrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ describe("ClientIntegration", function () {
await env.client.pingAll();
});

it("should fail on ping", async function () {
this.timeout(120000);

let error = null;
try {
await env.client.ping("0.0.100"); // Non exist Node ID
} catch (err) {
error = err;
}
expect(error).to.be.an("Error");
});

it("can set network name on custom network", async function () {
expect(clientTestnet.ledgerId).to.be.equal(LedgerId.TESTNET);
expect(clientPreviewNet.ledgerId).to.be.equal(LedgerId.PREVIEWNET);
Expand Down

0 comments on commit 2720c7f

Please sign in to comment.