Skip to content

Commit 7f625c5

Browse files
committed
tests: fixed failing ping test
The ping command handled an error and printed a different message as a result. Ping was updated to never throw an error so the distinction between the messages can no longer be made.
1 parent 1890801 commit 7f625c5

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

src/bin/nodes/CommandPing.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class CommandPing extends CommandPolykey {
1919
this.action(async (nodeId: NodeId, options) => {
2020
const { default: PolykeyClient } = await import('../../PolykeyClient');
2121
const nodesUtils = await import('../../nodes/utils');
22-
const nodesErrors = await import('../../nodes/errors');
2322
const nodesPB = await import('../../proto/js/polykey/v1/nodes/nodes_pb');
2423
const clientOptions = await binProcessors.processClientOptions(
2524
options.nodePath,
@@ -47,25 +46,11 @@ class CommandPing extends CommandPolykey {
4746
});
4847
const nodeMessage = new nodesPB.Node();
4948
nodeMessage.setNodeId(nodesUtils.encodeNodeId(nodeId));
50-
let statusMessage;
5149
let error;
52-
try {
53-
statusMessage = await binUtils.retryAuthentication(
54-
(auth) => pkClient.grpcClient.nodesPing(nodeMessage, auth),
55-
meta,
56-
);
57-
} catch (err) {
58-
if (err.cause instanceof nodesErrors.ErrorNodeGraphNodeIdNotFound) {
59-
error = new binErrors.ErrorCLINodePingFailed(
60-
`Failed to resolve node ID ${nodesUtils.encodeNodeId(
61-
nodeId,
62-
)} to an address.`,
63-
{ cause: err },
64-
);
65-
} else {
66-
throw err;
67-
}
68-
}
50+
const statusMessage = await binUtils.retryAuthentication(
51+
(auth) => pkClient.grpcClient.nodesPing(nodeMessage, auth),
52+
meta,
53+
);
6954
const status = { success: false, message: '' };
7055
status.success = statusMessage ? statusMessage.getSuccess() : false;
7156
if (!status.success && !error) {

tests/bin/nodes/ping.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ describe('ping', () => {
148148
expect(exitCode).not.toBe(0); // Should fail if node doesn't exist.
149149
expect(JSON.parse(stdout)).toEqual({
150150
success: false,
151-
message: `Failed to resolve node ID ${nodesUtils.encodeNodeId(
152-
fakeNodeId!,
153-
)} to an address.`,
151+
message: `No response received`,
154152
});
155153
},
156154
globalThis.failedConnectionTimeout,

0 commit comments

Comments
 (0)