Skip to content

Commit c6662b3

Browse files
committed
WIP
Test resolve
1 parent 137f93f commit c6662b3

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

tests/rpc/RPC.test.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import type { ContainerType, JSONRPCRequest } from '../../../Polykey/src/rpc/types';
1+
import type { ContainerType, JSONRPCRequest } from '../../src/types';
22
import type { ReadableStream } from 'stream/web';
3-
import type { JSONValue } from '../../../Polykey/src/types';
3+
import type { JSONValue } from '../../src/types';
44
import { TransformStream } from 'stream/web';
55
import { fc, testProp } from '@fast-check/jest';
66
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
7-
import * as utils from '../../../Polykey/src/utils';
8-
import RPCServer from '../../../Polykey/src/rpc/RPCServer';
9-
import RPCClient from '../../../Polykey/src/rpc/RPCClient';
7+
import * as rpcTestUtils from './utils';
8+
import * as utils from '../../src/utils';
9+
import RPCServer from '../../src/RPCServer';
10+
import RPCClient from '../../src/RPCClient';
1011
import {
1112
ClientHandler,
1213
DuplexHandler,
1314
RawHandler,
1415
ServerHandler,
1516
UnaryHandler,
16-
} from '../../../Polykey/src/rpc/handlers';
17+
} from '../../src/handlers';
1718
import {
1819
ClientCaller,
1920
DuplexCaller,
2021
RawCaller,
2122
ServerCaller,
2223
UnaryCaller,
23-
} from '../../../Polykey/src/rpc/callers';
24-
import * as rpcErrors from '../../../Polykey/src/rpc/errors';
25-
import * as rpcUtilsMiddleware from '../../../Polykey/src/rpc/utils/middleware';
26-
import * as rpcTestUtils from './utils';
24+
} from '../../src/callers';
25+
import * as rpcErrors from '../../src/errors';
26+
import * as rpcUtilsMiddleware from '../../src/utils/middleware';
2727

2828
describe('RPC', () => {
2929
const logger = new Logger(`RPC Test`, LogLevel.WARN, [new StreamHandler()]);
@@ -169,7 +169,7 @@ describe('RPC', () => {
169169
rpcClient.methods.testMethod({
170170
hello: 'world',
171171
}),
172-
).rejects.toThrow(rpcErrors.ErrorPolykeyRemote);
172+
).rejects.toThrow(rpcErrors.ErrorRPCRemote);
173173

174174
await rpcServer.destroy();
175175
await rpcClient.destroy();
@@ -420,7 +420,7 @@ describe('RPC', () => {
420420
});
421421

422422
const callProm = rpcClient.methods.testMethod(value);
423-
await expect(callProm).rejects.toThrow(rpcErrors.ErrorPolykeyRemote);
423+
await expect(callProm).rejects.toThrow(rpcErrors.ErrorRPCRemote);
424424
await expect(
425425
callProm.catch((e) => {
426426
throw e.cause;
@@ -476,7 +476,7 @@ describe('RPC', () => {
476476
});
477477

478478
const callProm = rpcClient.methods.testMethod(value);
479-
await expect(callProm).rejects.toThrow(rpcErrors.ErrorPolykeyRemote);
479+
await expect(callProm).rejects.toThrow(rpcErrors.ErrorRPCRemote);
480480
await expect(
481481
callProm.catch((e) => {
482482
throw e.cause;

tests/rpc/RPCClient.test.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
import type { ContextTimed } from '@matrixai/contexts';
2-
import type { JSONValue } from '../../../Polykey/src/types';
2+
import type { JSONValue } from '../../src/types';
33
import type {
44
JSONRPCRequest,
55
JSONRPCRequestMessage,
66
JSONRPCResponse,
77
JSONRPCResponseResult,
88
RPCStream,
9-
} from '../../../Polykey/src/rpc/types';
9+
} from '../../src/types';
1010
import { TransformStream, ReadableStream } from 'stream/web';
1111
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
1212
import { testProp, fc } from '@fast-check/jest';
13-
import RPCClient from '../../../Polykey/src/rpc/RPCClient';
14-
import RPCServer from '../../../Polykey/src/rpc/RPCServer';
15-
import * as rpcErrors from '../../../Polykey/src/rpc/errors';
13+
import * as rpcTestUtils from './utils';
14+
import RPCClient from '../../src/RPCClient';
15+
import RPCServer from '../../src/RPCServer';
16+
import * as rpcErrors from '../../src/errors';
1617
import {
1718
ClientCaller,
1819
DuplexCaller,
1920
RawCaller,
2021
ServerCaller,
2122
UnaryCaller,
22-
} from '../../../Polykey/src/rpc/callers';
23-
import * as rpcUtilsMiddleware from '../../../Polykey/src/rpc/utils/middleware';
24-
import { promise, sleep } from '../../../Polykey/src/utils';
25-
import * as rpcTestUtils from './utils';
23+
} from '../../src/callers';
24+
import * as rpcUtilsMiddleware from '../../src/utils/middleware';
25+
import { promise, sleep } from '../../src/utils';
26+
import { ErrorRPCRemote } from '../../src/errors';
2627

2728
describe(`${RPCClient.name}`, () => {
2829
const logger = new Logger(`${RPCServer.name} Test`, LogLevel.WARN, [
@@ -285,7 +286,7 @@ describe(`${RPCClient.name}`, () => {
285286
// Only consume
286287
}
287288
})();
288-
await expect(callProm).rejects.toThrow(rpcErrors.ErrorPolykeyRemote);
289+
await expect(callProm).rejects.toThrow(rpcErrors.ErrorRPCRemote);
289290
await outputResult;
290291
await rpcClient.destroy();
291292
},
@@ -324,7 +325,7 @@ describe(`${RPCClient.name}`, () => {
324325
// Only consume
325326
}
326327
})();
327-
await expect(callProm).rejects.toThrow(rpcErrors.ErrorPolykeyRemote);
328+
await expect(callProm).rejects.toThrow(rpcErrors.ErrorRPCRemote);
328329
await outputResult;
329330
await rpcClient.destroy();
330331
},
@@ -366,7 +367,7 @@ describe(`${RPCClient.name}`, () => {
366367
// Only consume
367368
}
368369
})();
369-
await expect(callProm).rejects.toThrow(rpcErrors.ErrorPolykeyRemote);
370+
await expect(callProm).rejects.toThrow(rpcErrors.ErrorRPCRemote);
370371
await outputResult;
371372
await rpcClient.destroy();
372373
},

tests/rpc/RPCServer.test.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@ import type {
55
JSONRPCResponse,
66
JSONRPCResponseError,
77
RPCStream,
8-
} from '../../../Polykey/src/rpc/types';
9-
import type { JSONValue } from '../../../Polykey/src/types';
10-
import type { NodeId } from '../../../Polykey/src/ids';
11-
import type { RPCErrorEvent } from '../../../Polykey/src/rpc/events';
8+
} from '../../src/types';
9+
import type { JSONValue } from '../../src/types';
10+
import type { RPCErrorEvent } from '../../src/events';
1211
import { ReadableStream, TransformStream, WritableStream } from 'stream/web';
1312
import { fc, testProp } from '@fast-check/jest';
1413
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
15-
import RPCServer from '../../../Polykey/src/rpc/RPCServer';
16-
import * as rpcErrors from '../../../Polykey/src/rpc/errors';
17-
import * as rpcUtils from '../../../Polykey/src/rpc/utils';
14+
import * as rpcTestUtils from './utils';
15+
import RPCServer from '../../src/RPCServer';
16+
import * as rpcErrors from '../../src/errors';
17+
import * as rpcUtils from '../../src/utils';
1818
import {
1919
ClientHandler,
2020
DuplexHandler,
2121
RawHandler,
2222
ServerHandler,
2323
UnaryHandler,
24-
} from '../../../Polykey/src/rpc/handlers';
25-
import * as rpcUtilsMiddleware from '../../../Polykey/src/rpc/utils/middleware';
26-
import { promise, sleep } from '../../../Polykey/src/utils';
27-
import * as rpcTestUtils from './utils';
24+
} from '../../src/handlers';
25+
import * as rpcUtilsMiddleware from '../../src/utils/middleware';
26+
import { promise, sleep } from '../../src/utils';
2827

2928
describe(`${RPCServer.name}`, () => {
3029
const logger = new Logger(`${RPCServer.name} Test`, LogLevel.WARN, [
@@ -272,7 +271,6 @@ describe(`${RPCServer.name}`, () => {
272271
localPort: 12341,
273272
remoteCertificates: [],
274273
remoteHost: 'hostA',
275-
remoteNodeId: 'asd' as unknown as NodeId,
276274
remotePort: 12341,
277275
};
278276
let handledMeta;

0 commit comments

Comments
 (0)