Skip to content

Commit

Permalink
tests: final test cleaning
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
tegefaulkes committed Oct 9, 2023
1 parent 7578317 commit 1e78d78
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
10 changes: 6 additions & 4 deletions tests/PolykeyClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PolykeyClient, PolykeyAgent } from '@';
import { Session } from '@/sessions';
import config from '@/config';
import * as keysUtils from '@/keys/utils/index';
import WebSocketClient from '@/websockets/WebSocketClient';
import { WebSocketClient } from '@matrixai/ws';

describe('PolykeyClient', () => {
const password = 'password';
Expand Down Expand Up @@ -54,13 +54,15 @@ describe('PolykeyClient', () => {
await session.writeToken('dummy' as SessionToken);
// Using fresh: true means that any token would be destroyed
const webSocketClient = await WebSocketClient.createWebSocketClient({
expectedNodeIds: [pkAgent.keyRing.getNodeId()],
config: {
verifyPeer: false,
},
host: pkAgent.clientServiceHost,
port: pkAgent.clientServicePort,
logger,
});
const pkClient = await PolykeyClient.createPolykeyClient({
streamFactory: (ctx) => webSocketClient.startConnection(ctx),
streamFactory: () => webSocketClient.connection.newStream(),
nodePath,
fs,
logger,
Expand All @@ -72,6 +74,6 @@ describe('PolykeyClient', () => {
expect(await session.readToken()).toBeDefined();
await pkClient.destroy();
expect(await session.readToken()).toBeUndefined();
await webSocketClient.destroy(true);
await webSocketClient.destroy({ force: true });
});
});
4 changes: 2 additions & 2 deletions tests/nodes/agent/handlers/nodesClaimsGet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('nodesClaimsGet', () => {
});

// Setting up client
rpcClient = await RPCClient.createRPCClient({
rpcClient = new RPCClient({
manifest: clientManifest,
streamFactory: async () => {
return quicClient.connection.newStream();
Expand All @@ -162,7 +162,7 @@ describe('nodesClaimsGet', () => {
});
});
afterEach(async () => {
await rpcServer.destroy({ force: true });
await rpcServer.stop({ force: true });
await quicServer.stop({ force: true });
await sigchain.stop();
await db.stop();
Expand Down
8 changes: 4 additions & 4 deletions tests/nodes/agent/handlers/nodesClosestLocalNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ describe('nodesClosestLocalNode', () => {
nodeGraph,
}),
};
rpcServer = await RPCServer.createRPCServer({
manifest: serverManifest,
rpcServer = new RPCServer({
logger,
});
await rpcServer.start({ manifest: serverManifest });
const tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair);
quicServer = new QUICServer({
config: {
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('nodesClosestLocalNode', () => {
});

// Setting up client
rpcClient = await RPCClient.createRPCClient({
rpcClient = new RPCClient({
manifest: clientManifest,
streamFactory: async () => {
return quicClient.connection.newStream();
Expand All @@ -161,7 +161,7 @@ describe('nodesClosestLocalNode', () => {
});
});
afterEach(async () => {
await rpcServer.destroy({ force: true });
await rpcServer.stop({ force: true });
await quicServer.stop({ force: true });
await nodeGraph.stop();
await db.stop();
Expand Down
8 changes: 4 additions & 4 deletions tests/nodes/agent/handlers/nodesCrossSignClaim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ describe('nodesCrossSignClaim', () => {
nodeManager,
}),
};
rpcServer = await RPCServer.createRPCServer({
manifest: serverManifest,
rpcServer = new RPCServer({
logger,
});
await rpcServer.start({ manifest: serverManifest });
const tlsConfigServer = await tlsTestsUtils.createTLSConfig(
keyRing.keyPair,
);
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('nodesCrossSignClaim', () => {
});

// Setting up client
rpcClient = await RPCClient.createRPCClient({
rpcClient = new RPCClient({
manifest: clientManifest,
streamFactory: async () => {
return quicClient.connection.newStream();
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('nodesCrossSignClaim', () => {
});
afterEach(async () => {
await taskManager.stop();
await rpcServer.destroy({ force: true });
await rpcServer.stop({ force: true });
await quicServer.stop({ force: true });
await nodeGraph.stop();
await sigchain.stop();
Expand Down
8 changes: 4 additions & 4 deletions tests/nodes/agent/handlers/nodesHolePunchMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ describe('nodesHolePunchMessage', () => {
logger,
}),
};
rpcServer = await RPCServer.createRPCServer({
manifest: serverManifest,
rpcServer = new RPCServer({
logger,
});
await rpcServer.start({ manifest: serverManifest });
const tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair);
quicServer = new QUICServer({
config: {
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('nodesHolePunchMessage', () => {
});

// Setting up client
rpcClient = await RPCClient.createRPCClient({
rpcClient = new RPCClient({
manifest: clientManifest,
streamFactory: async () => {
return quicClient.connection.newStream();
Expand All @@ -232,7 +232,7 @@ describe('nodesHolePunchMessage', () => {
});
});
afterEach(async () => {
await rpcServer.destroy({ force: true });
await rpcServer.stop({ force: true });
await taskManager.stopProcessing();
await taskManager.stopTasks();
await quicServer.stop({ force: true });
Expand Down
8 changes: 4 additions & 4 deletions tests/nodes/agent/handlers/notificationsSend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ describe('notificationsSend', () => {
notificationsManager,
}),
};
rpcServer = await RPCServer.createRPCServer({
manifest: serverManifest,
rpcServer = new RPCServer({
logger,
});
await rpcServer.start({ manifest: serverManifest });
const tlsConfig = await tlsTestsUtils.createTLSConfig(keyRing.keyPair);
quicServer = new QUICServer({
config: {
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('notificationsSend', () => {
});

// Setting up client
rpcClient = await RPCClient.createRPCClient({
rpcClient = new RPCClient({
manifest: clientManifest,
streamFactory: async () => {
return quicClient.connection.newStream();
Expand Down Expand Up @@ -260,7 +260,7 @@ describe('notificationsSend', () => {
afterEach(async () => {
await taskManager.stopProcessing();
await taskManager.stopTasks();
await rpcServer.destroy({ force: true });
await rpcServer.stop({ force: true });
await quicServer.stop({ force: true });
await notificationsManager.stop();
await nodeManager.stop();
Expand Down

0 comments on commit 1e78d78

Please sign in to comment.