Skip to content

Commit 7c3fb75

Browse files
committed
tests: fixing up tests
* Related #527 [ci skip]
1 parent 8f70698 commit 7c3fb75

16 files changed

+103
-149
lines changed

src/PolykeyAgent.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ class PolykeyAgent {
9696
keyRingConfig = {},
9797
certManagerConfig = {},
9898
networkConfig = {},
99-
quicServerConfig = {},
100-
quicClientConfig = {},
99+
quicConfig = {},
101100
nodeConnectionManagerConfig = {},
102101
seedNodes = {},
103102
workers,
@@ -149,8 +148,7 @@ class PolykeyAgent {
149148
connectionHolePunchIntervalTime?: number;
150149
};
151150
networkConfig?: NetworkConfig;
152-
quicServerConfig?: PolykeyQUICConfig;
153-
quicClientConfig?: PolykeyQUICConfig;
151+
quicConfig?: PolykeyQUICConfig;
154152
seedNodes?: SeedNodes;
155153
workers?: number;
156154
status?: Status;
@@ -198,14 +196,9 @@ class PolykeyAgent {
198196
...config.defaults.networkConfig,
199197
...utils.filterEmptyObject(networkConfig),
200198
};
201-
const quicServerConfig_ = {
202-
...config.defaults.quicServerConfig,
203-
...utils.filterEmptyObject(quicServerConfig),
204-
};
205-
// TODO: rename
206-
const quicClientConfig_ = {
207-
...config.defaults.quicClientConfig,
208-
...utils.filterEmptyObject(quicClientConfig),
199+
const quicConfig_ = {
200+
...config.defaults.quicConfig,
201+
...utils.filterEmptyObject(quicConfig),
209202
};
210203
await utils.mkdirExists(fs, nodePath);
211204
const statusPath = path.join(nodePath, config.defaults.statusBase);
@@ -401,7 +394,7 @@ class PolykeyAgent {
401394
nodeGraph,
402395
seedNodes,
403396
quicSocket,
404-
quicConfig: quicClientConfig_,
397+
quicConfig: quicConfig_,
405398
...nodeConnectionManagerConfig_,
406399
tlsConfig,
407400
crypto,

src/bootstrap/utils.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Sigchain } from '../sigchain';
1414
import { ACL } from '../acl';
1515
import { GestaltGraph } from '../gestalts';
1616
import { KeyRing } from '../keys';
17-
import { NodeConnectionManager, NodeGraph, NodeManager } from '../nodes';
17+
import { NodeGraph, NodeManager } from '../nodes';
1818
import { VaultManager } from '../vaults';
1919
import { NotificationsManager } from '../notifications';
2020
import { mkdirExists } from '../utils';
@@ -153,21 +153,11 @@ async function bootstrapState({
153153
logger,
154154
lazy: true,
155155
});
156-
const nodeConnectionManager = new NodeConnectionManager({
157-
// No streams are created
158-
handleStream: () => {},
159-
keyRing,
160-
nodeGraph,
161-
quicClientConfig: {} as any, // No connections are attempted
162-
crypto: {} as any, // No connections are attempted
163-
quicSocket: {} as any, // No connections are attempted
164-
logger: logger.getChild(NodeConnectionManager.name),
165-
});
166156
const nodeManager = new NodeManager({
167157
db,
168158
keyRing,
169159
nodeGraph,
170-
nodeConnectionManager,
160+
nodeConnectionManager: {} as any, // No connections are attempted
171161
sigchain,
172162
taskManager,
173163
gestaltGraph,
@@ -177,7 +167,7 @@ async function bootstrapState({
177167
await NotificationsManager.createNotificationsManager({
178168
acl,
179169
db,
180-
nodeConnectionManager,
170+
nodeConnectionManager: {} as any, // No connections are attempted
181171
nodeManager,
182172
keyRing,
183173
logger: logger.getChild(NotificationsManager.name),
@@ -188,7 +178,7 @@ async function bootstrapState({
188178
db,
189179
gestaltGraph,
190180
keyRing,
191-
nodeConnectionManager,
181+
nodeConnectionManager: {} as any, // No connections are attempted
192182
vaultsPath,
193183
notificationsManager,
194184
logger: logger.getChild(VaultManager.name),

src/config.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ const config = {
107107
handlerTimeoutTime: 60_000, // 1 minute
108108
handlerTimeoutGraceTime: 2_000, // 2 seconds
109109
},
110-
quicServerConfig: {
111-
keepAliveIntervalTime: 10_000, // 10 seconds
112-
maxIdleTimeout: 60_000, // 1 minute
113-
},
114-
quicClientConfig: {
110+
quicConfig: {
115111
keepAliveIntervalTime: 10_000, // 10 seconds
116112
maxIdleTimeout: 60_000, // 1 minute
117113
},

tests/agent/handlers/nodesClaimsGet.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ describe('nodesClaimsGet', () => {
8787
cert: tlsConfig.certChainPem,
8888
verifyPeer: false,
8989
},
90-
crypto,
90+
crypto: {
91+
key: keysUtils.generateKey(),
92+
ops: crypto,
93+
},
9194
logger,
9295
});
9396
const handleStream = async (
@@ -134,7 +137,9 @@ describe('nodesClaimsGet', () => {
134137
logger,
135138
});
136139
quicClient = await QUICClient.createQUICClient({
137-
crypto,
140+
crypto: {
141+
ops: crypto,
142+
},
138143
config: {
139144
verifyPeer: false,
140145
},

tests/agent/handlers/nodesClosestLocalNode.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ describe('nodesClosestLocalNode', () => {
8686
cert: tlsConfig.certChainPem,
8787
verifyPeer: false,
8888
},
89-
crypto,
89+
crypto: {
90+
key: keysUtils.generateKey(),
91+
ops: crypto,
92+
},
9093
logger,
9194
});
9295
const handleStream = async (
@@ -133,7 +136,9 @@ describe('nodesClosestLocalNode', () => {
133136
logger,
134137
});
135138
quicClient = await QUICClient.createQUICClient({
136-
crypto,
139+
crypto: {
140+
ops: crypto,
141+
},
137142
config: {
138143
verifyPeer: false,
139144
},

tests/agent/handlers/nodesCrossSignClaim.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ describe('nodesCrossSignClaim', () => {
136136
verifyPeer: true,
137137
verifyAllowFail: true,
138138
},
139-
crypto,
139+
crypto: {
140+
key: keysUtils.generateKey(),
141+
ops: crypto,
142+
},
140143
logger,
141144
});
142145
const handleStream = async (
@@ -186,7 +189,9 @@ describe('nodesCrossSignClaim', () => {
186189
localNodeId = keysUtils.publicKeyToNodeId(clientKeyPair.publicKey);
187190
const tlsConfigClient = await tlsTestsUtils.createTLSConfig(clientKeyPair);
188191
quicClient = await QUICClient.createQUICClient({
189-
crypto,
192+
crypto: {
193+
ops: crypto,
194+
},
190195
config: {
191196
key: tlsConfigClient.keyPrivatePem,
192197
cert: tlsConfigClient.certChainPem,

tests/agent/handlers/nodesHolePunchMessage.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ describe('nodesHolePunchMessage', () => {
105105
keyRing.keyPair,
106106
);
107107
nodeConnectionManager = new NodeConnectionManager({
108-
quicClientConfig: {
109-
key: tlsConfigClient.keyPrivatePem,
110-
cert: tlsConfigClient.certChainPem,
111-
},
108+
tlsConfig: tlsConfigClient,
112109
crypto,
113110
quicSocket,
114111
keyRing,
@@ -128,7 +125,7 @@ describe('nodesHolePunchMessage', () => {
128125
logger,
129126
});
130127
await nodeManager.start();
131-
await nodeConnectionManager.start({ nodeManager });
128+
await nodeConnectionManager.start({ nodeManager, handleStream: () => {} });
132129
await taskManager.startProcessing();
133130

134131
// Setting up server
@@ -153,7 +150,10 @@ describe('nodesHolePunchMessage', () => {
153150
verifyPeer: true,
154151
verifyAllowFail: true,
155152
},
156-
crypto,
153+
crypto: {
154+
key: keysUtils.generateKey(),
155+
ops: crypto,
156+
},
157157
logger,
158158
});
159159
const handleStream = async (
@@ -200,7 +200,9 @@ describe('nodesHolePunchMessage', () => {
200200
logger,
201201
});
202202
quicClient = await QUICClient.createQUICClient({
203-
crypto,
203+
crypto: {
204+
ops: crypto,
205+
},
204206
config: {
205207
key: tlsConfigClient.keyPrivatePem,
206208
cert: tlsConfigClient.certChainPem,

tests/agent/handlers/notificationsSend.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ describe('notificationsSend', () => {
128128
keyRing.keyPair,
129129
);
130130
nodeConnectionManager = new NodeConnectionManager({
131-
quicClientConfig: {
132-
key: tlsConfigClient.keyPrivatePem,
133-
cert: tlsConfigClient.certChainPem,
134-
},
131+
tlsConfig: tlsConfigClient,
135132
crypto,
136133
quicSocket,
137134
keyRing,
@@ -151,7 +148,7 @@ describe('notificationsSend', () => {
151148
logger,
152149
});
153150
await nodeManager.start();
154-
await nodeConnectionManager.start({ nodeManager });
151+
await nodeConnectionManager.start({ nodeManager, handleStream: () => {} });
155152
await taskManager.startProcessing();
156153
notificationsManager =
157154
await NotificationsManager.createNotificationsManager({
@@ -183,7 +180,10 @@ describe('notificationsSend', () => {
183180
verifyPeer: true,
184181
verifyAllowFail: true,
185182
},
186-
crypto,
183+
crypto: {
184+
key: keysUtils.generateKey(),
185+
ops: crypto,
186+
},
187187
logger,
188188
});
189189
const handleStream = async (
@@ -230,7 +230,9 @@ describe('notificationsSend', () => {
230230
logger,
231231
});
232232
quicClient = await QUICClient.createQUICClient({
233-
crypto,
233+
crypto: {
234+
ops: crypto,
235+
},
234236
config: {
235237
key: tlsConfigClient.keyPrivatePem,
236238
cert: tlsConfigClient.certChainPem,

tests/client/handlers/agent.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ describe('agentStatus', () => {
200200
nodeIdEncoded: nodesUtils.encodeNodeId(pkAgent.keyRing.getNodeId()),
201201
clientHost: pkAgent.webSocketServerClient.getHost(),
202202
clientPort: pkAgent.webSocketServerClient.getPort(),
203-
agentHost: pkAgent.quicServerAgent.host,
204-
agentPort: pkAgent.quicServerAgent.port,
203+
agentHost: pkAgent.quicSocket.host,
204+
agentPort: pkAgent.quicSocket.port,
205205
publicKeyJwk: keysUtils.publicKeyToJWK(pkAgent.keyRing.keyPair.publicKey),
206206
certChainPEM: await pkAgent.certManager.getCertPEMsChainPEM(),
207207
});

tests/client/handlers/gestalts.test.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,8 @@ describe('gestaltsDiscoverByIdentity', () => {
448448
nodeConnectionManager = new NodeConnectionManager({
449449
keyRing,
450450
nodeGraph,
451-
quicClientConfig: {
452-
// @ts-ignore: TLS not needed for this test
453-
key: undefined,
454-
// @ts-ignore: TLS not needed for this test
455-
cert: undefined,
456-
},
451+
// @ts-ignore: TLS not needed for this test
452+
tlsConfig: {},
457453
crypto,
458454
quicSocket,
459455
connectionConnectTime: 2000,
@@ -471,7 +467,7 @@ describe('gestaltsDiscoverByIdentity', () => {
471467
logger,
472468
});
473469
await nodeManager.start();
474-
await nodeConnectionManager.start({ nodeManager });
470+
await nodeConnectionManager.start({ nodeManager, handleStream: () => {} });
475471
discovery = await Discovery.createDiscovery({
476472
db,
477473
gestaltGraph,
@@ -637,12 +633,8 @@ describe('gestaltsDiscoverByNode', () => {
637633
nodeConnectionManager = new NodeConnectionManager({
638634
keyRing,
639635
nodeGraph,
640-
quicClientConfig: {
641-
// @ts-ignore: TLS not needed for this test
642-
key: undefined,
643-
// @ts-ignore: TLS not needed for this test
644-
cert: undefined,
645-
},
636+
// @ts-ignore: TLS not needed for this test
637+
tlsConfig: {},
646638
crypto,
647639
quicSocket,
648640
connectionConnectTime: 2000,
@@ -660,7 +652,7 @@ describe('gestaltsDiscoverByNode', () => {
660652
logger,
661653
});
662654
await nodeManager.start();
663-
await nodeConnectionManager.start({ nodeManager });
655+
await nodeConnectionManager.start({ nodeManager, handleStream: () => {} });
664656
discovery = await Discovery.createDiscovery({
665657
db,
666658
gestaltGraph,
@@ -1264,10 +1256,8 @@ describe('gestaltsGestaltTrustByIdentity', () => {
12641256
nodeConnectionManager = new NodeConnectionManager({
12651257
keyRing,
12661258
nodeGraph,
1267-
quicClientConfig: {
1268-
key: tlsConfig.keyPrivatePem,
1269-
cert: tlsConfig.certChainPem,
1270-
},
1259+
// @ts-ignore: TLS not needed for this test
1260+
tlsConfig: {},
12711261
crypto,
12721262
quicSocket,
12731263
connectionConnectTime: 2000,
@@ -1285,7 +1275,7 @@ describe('gestaltsGestaltTrustByIdentity', () => {
12851275
logger,
12861276
});
12871277
await nodeManager.start();
1288-
await nodeConnectionManager.start({ nodeManager });
1278+
await nodeConnectionManager.start({ nodeManager, handleStream: () => {} });
12891279
discovery = await Discovery.createDiscovery({
12901280
db,
12911281
gestaltGraph,
@@ -1785,12 +1775,8 @@ describe('gestaltsGestaltTrustByNode', () => {
17851775
nodeConnectionManager = new NodeConnectionManager({
17861776
keyRing,
17871777
nodeGraph,
1788-
quicClientConfig: {
1789-
// @ts-ignore: TLS not needed for this test
1790-
key: undefined,
1791-
// @ts-ignore: TLS not needed for this test
1792-
cert: undefined,
1793-
},
1778+
// @ts-ignore: TLS not needed for this test
1779+
tlsConfig: {},
17941780
crypto,
17951781
quicSocket,
17961782
connectionConnectTime: 2000,
@@ -1808,10 +1794,10 @@ describe('gestaltsGestaltTrustByNode', () => {
18081794
logger,
18091795
});
18101796
await nodeManager.start();
1811-
await nodeConnectionManager.start({ nodeManager });
1797+
await nodeConnectionManager.start({ nodeManager, handleStream: () => {} });
18121798
await nodeManager.setNode(nodeIdRemote, {
1813-
host: node.quicServerAgent.host as Host,
1814-
port: node.quicServerAgent.port as Port,
1799+
host: node.quicSocket.host as Host,
1800+
port: node.quicSocket.port as Port,
18151801
});
18161802
discovery = await Discovery.createDiscovery({
18171803
db,

0 commit comments

Comments
 (0)