Skip to content

Commit

Permalink
test: added test for if the proxies are connected before a `NodeConne…
Browse files Browse the repository at this point in the history
…ction` is made

#369
  • Loading branch information
tegefaulkes committed Apr 6, 2022
1 parent 105331d commit d9fd1a0
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/nodes/NodeConnection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,47 @@ describe(`${NodeConnection.name} test`, () => {
});
await conn.destroy();
});
test('connects to its target but proxies connect first', async () => {
await clientproxy.openConnectionForward(
targetNodeId,
localHost,
targetPort,
);
const conn = await NodeConnection.createNodeConnection({
targetNodeId: targetNodeId,
targetHost: localHost,
targetPort: targetPort,
proxy: clientproxy,
keyManager: clientKeyManager,
nodeConnectionManager: dummyNodeConnectionManager,
destroyCallback,
logger: logger,
clientFactory: async (args) =>
GRPCClientAgent.createGRPCClientAgent(args),
});
// Because the connection will not have enough time to compose before we
// attempt to acquire the connection info, we need to wait and poll it
const connInfo = await poll<ConnectionInfo | undefined>(
async () => {
return serverProxy.getConnectionInfoByProxy(localHost, sourcePort);
},
(e) => {
if (e instanceof networkErrors.ErrorConnectionNotComposed) return false;
if (e instanceof networkErrors.ErrorConnectionNotRunning) return false;
return true;
},
);
expect(connInfo).toBeDefined();
expect(connInfo).toMatchObject({
remoteNodeId: sourceNodeId,
remoteCertificates: expect.any(Array),
localHost: localHost,
localPort: targetPort,
remoteHost: localHost,
remotePort: sourcePort,
});
await conn.destroy();
});
test('grpcCall after connection drops', async () => {
let nodeConnection: NodeConnection<GRPCClientAgent> | undefined;
let polykeyAgent: PolykeyAgent | undefined;
Expand Down

0 comments on commit d9fd1a0

Please sign in to comment.