Skip to content

Commit 3d210f0

Browse files
test: check for at least one successfull run (#2730)
Signed-off-by: Ivaylo Nikolov <[email protected]>
1 parent 979db6d commit 3d210f0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

common_js_test/src/test.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
const { Client, AccountBalanceQuery } = require("@hashgraph/sdk");
22

33
describe("CommonJS", function () {
4-
it("it should query each node's balance", async function () {
4+
it("should query each node's balance", async function () {
55
const client = Client.forTestnet();
66

7+
let succeededAtLeastOnce = false;
8+
9+
// Iterate over the nodes in the network
710
for (const [, nodeAccountId] of Object.entries(client.network)) {
8-
await new AccountBalanceQuery()
9-
.setNodeAccountIds([nodeAccountId])
10-
.setAccountId(nodeAccountId)
11-
.execute(client);
11+
try {
12+
await new AccountBalanceQuery()
13+
.setNodeAccountIds([nodeAccountId])
14+
.setAccountId(nodeAccountId)
15+
.execute(client);
16+
succeededAtLeastOnce = true;
17+
} catch (error) {
18+
console.log(`Failed for ${nodeAccountId}`);
19+
}
1220
}
1321
client.close();
22+
if (!succeededAtLeastOnce) {
23+
throw new Error("No successful query attempts were made.");
24+
}
1425
});
1526
});

0 commit comments

Comments
 (0)