@dxos/client-services 0.6.11 → 0.6.12-main.5cc132e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-QYVLLBAA.mjs → chunk-7FTR2DGP.mjs} +2 -2
- package/dist/lib/browser/chunk-7FTR2DGP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-F7G2TXVG.cjs → chunk-KUHUPLSZ.cjs} +5 -5
- package/dist/lib/node/chunk-KUHUPLSZ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +45 -45
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/node-esm/chunk-QGQGMTAW.mjs +7714 -0
- package/dist/lib/node-esm/chunk-QGQGMTAW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +415 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/testing/index.mjs +418 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/authenticator.node.test.d.ts +2 -0
- package/dist/types/src/packlets/identity/authenticator.node.test.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/testing/setup.d.ts +3 -0
- package/dist/types/src/testing/setup.d.ts.map +1 -0
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +42 -39
- package/src/packlets/devices/devices-service.test.ts +4 -5
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +1 -0
- package/src/packlets/identity/{authenticator.test.ts → authenticator.node.test.ts} +2 -3
- package/src/packlets/identity/identity-manager.test.ts +4 -5
- package/src/packlets/identity/identity-service.test.ts +4 -8
- package/src/packlets/identity/identity.test.ts +4 -5
- package/src/packlets/invitations/device-invitation-protocol.test.ts +7 -4
- package/src/packlets/invitations/invitations-handler.test.ts +14 -7
- package/src/packlets/invitations/space-invitation-protocol.test.ts +4 -3
- package/src/packlets/logging/logging.test.ts +1 -2
- package/src/packlets/network/network-service.test.ts +2 -3
- package/src/packlets/services/automerge-host.test.ts +6 -4
- package/src/packlets/services/service-context.test.ts +3 -1
- package/src/packlets/services/service-host.test.ts +8 -12
- package/src/packlets/services/service-registry.test.ts +1 -2
- package/src/packlets/spaces/data-space-manager.test.ts +2 -2
- package/src/packlets/spaces/notarization-plugin.test.ts +2 -3
- package/src/packlets/spaces/spaces-service.test.ts +5 -9
- package/src/packlets/storage/storage.ts +0 -1
- package/src/packlets/system/system-service.test.ts +1 -2
- package/src/testing/setup.ts +11 -0
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-QYVLLBAA.mjs.map +0 -7
- package/dist/lib/node/chunk-F7G2TXVG.cjs.map +0 -7
- package/dist/types/src/packlets/identity/authenticator.test.d.ts +0 -2
- package/dist/types/src/packlets/identity/authenticator.test.d.ts.map +0 -1
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { type DevicesService, type Device } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
12
11
|
|
|
13
12
|
import { DevicesServiceImpl } from './devices-service';
|
|
14
13
|
import { type ServiceContext } from '../services';
|
|
@@ -36,7 +35,7 @@ describe('DevicesService', () => {
|
|
|
36
35
|
query.subscribe(({ devices }) => {
|
|
37
36
|
result.wake(devices);
|
|
38
37
|
});
|
|
39
|
-
|
|
38
|
+
onTestFinished(() => query.close());
|
|
40
39
|
expect(device.profile?.label).to.equal('test-device');
|
|
41
40
|
});
|
|
42
41
|
});
|
|
@@ -51,7 +50,7 @@ describe('DevicesService', () => {
|
|
|
51
50
|
},
|
|
52
51
|
(err) => log.catch(err),
|
|
53
52
|
);
|
|
54
|
-
|
|
53
|
+
onTestFinished(() => query.close().catch((err) => log.catch(err)));
|
|
55
54
|
expect(await result.wait()).to.be.length(0);
|
|
56
55
|
});
|
|
57
56
|
|
|
@@ -61,7 +60,7 @@ describe('DevicesService', () => {
|
|
|
61
60
|
query.subscribe(({ devices }) => {
|
|
62
61
|
result.wake(devices);
|
|
63
62
|
});
|
|
64
|
-
|
|
63
|
+
onTestFinished(() => query.close());
|
|
65
64
|
expect(await result.wait()).to.be.length(0);
|
|
66
65
|
|
|
67
66
|
result = new Trigger<Device[] | undefined>();
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import expect from '
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
8
|
import { createCredentialSignerWithKey } from '@dxos/credentials';
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { Keyring } from '@dxos/keyring';
|
|
11
11
|
import { PublicKey } from '@dxos/keys';
|
|
12
|
-
import { describe, test } from '@dxos/test';
|
|
13
12
|
import { ComplexSet } from '@dxos/util';
|
|
14
13
|
|
|
15
14
|
import { createAuthProvider, TrustedKeySetAuthVerifier } from './authenticator';
|
|
@@ -30,5 +29,5 @@ describe('identity/authenticator', () => {
|
|
|
30
29
|
const credential = await authProvider(nonce);
|
|
31
30
|
invariant(credential);
|
|
32
31
|
expect(await authVerifier.verifier(nonce, credential)).toBeTruthy();
|
|
33
|
-
})
|
|
32
|
+
});
|
|
34
33
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test, onTestFinished } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { valueEncoding, MetadataStore, SpaceManager, AuthStatus } from '@dxos/echo-pipeline';
|
|
@@ -13,7 +13,6 @@ import { MemoryTransportFactory, SwarmNetworkManager } from '@dxos/network-manag
|
|
|
13
13
|
import type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
14
14
|
import { createStorage, type Storage, StorageType } from '@dxos/random-access-storage';
|
|
15
15
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
16
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
17
16
|
|
|
18
17
|
import { IdentityManager } from './identity-manager';
|
|
19
18
|
|
|
@@ -39,7 +38,7 @@ describe('identity/identity-manager', () => {
|
|
|
39
38
|
}),
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
onTestFinished(() => feedStore.close());
|
|
43
42
|
|
|
44
43
|
const networkManager = new SwarmNetworkManager({
|
|
45
44
|
signalManager: new MemorySignalManager(signalContext),
|
|
@@ -64,7 +63,7 @@ describe('identity/identity-manager', () => {
|
|
|
64
63
|
test('creates identity', async () => {
|
|
65
64
|
const { identityManager } = await setupPeer();
|
|
66
65
|
await identityManager.open(new Context());
|
|
67
|
-
|
|
66
|
+
onTestFinished(() => identityManager.close());
|
|
68
67
|
|
|
69
68
|
const identity = await identityManager.createIdentity();
|
|
70
69
|
expect(identity).to.exist;
|
|
@@ -95,7 +94,7 @@ describe('identity/identity-manager', () => {
|
|
|
95
94
|
test('update profile', async () => {
|
|
96
95
|
const { identityManager } = await setupPeer();
|
|
97
96
|
await identityManager.open(new Context());
|
|
98
|
-
|
|
97
|
+
onTestFinished(() => identityManager.close());
|
|
99
98
|
|
|
100
99
|
const identity = await identityManager.createIdentity();
|
|
101
100
|
expect(identity.profileDocument?.displayName).to.be.undefined;
|
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
7
|
import { Trigger } from '@dxos/async';
|
|
9
8
|
import { Context } from '@dxos/context';
|
|
10
9
|
import { PublicKey } from '@dxos/keys';
|
|
11
10
|
import { type Identity, type IdentityService } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
13
11
|
|
|
14
12
|
import { IdentityServiceImpl } from './identity-service';
|
|
15
13
|
import { type ServiceContext } from '../services';
|
|
16
14
|
import { createServiceContext } from '../testing';
|
|
17
15
|
|
|
18
|
-
chai.use(chaiAsPromised);
|
|
19
|
-
|
|
20
16
|
describe('IdentityService', () => {
|
|
21
17
|
let serviceContext: ServiceContext;
|
|
22
18
|
let identityService: IdentityService;
|
|
@@ -49,7 +45,7 @@ describe('IdentityService', () => {
|
|
|
49
45
|
|
|
50
46
|
test('fails to create identity if one already exists', async () => {
|
|
51
47
|
await identityService.createIdentity({});
|
|
52
|
-
await expect(identityService.createIdentity({})).
|
|
48
|
+
await expect(identityService.createIdentity({})).rejects.toThrowError('Identity already exists');
|
|
53
49
|
});
|
|
54
50
|
});
|
|
55
51
|
|
|
@@ -72,7 +68,7 @@ describe('IdentityService', () => {
|
|
|
72
68
|
query.subscribe(({ identity }) => {
|
|
73
69
|
result.wake(identity);
|
|
74
70
|
});
|
|
75
|
-
|
|
71
|
+
onTestFinished(() => query.close());
|
|
76
72
|
expect(await result.wait()).to.be.undefined;
|
|
77
73
|
});
|
|
78
74
|
|
|
@@ -82,7 +78,7 @@ describe('IdentityService', () => {
|
|
|
82
78
|
query.subscribe(({ identity }) => {
|
|
83
79
|
result.wake(identity);
|
|
84
80
|
});
|
|
85
|
-
|
|
81
|
+
onTestFinished(() => query.close());
|
|
86
82
|
expect(await result.wait()).to.be.undefined;
|
|
87
83
|
|
|
88
84
|
result = new Trigger<Identity | undefined>();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import expect from '
|
|
5
|
+
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { CredentialGenerator, verifyCredential } from '@dxos/credentials';
|
|
@@ -24,7 +24,6 @@ import { type FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';
|
|
|
24
24
|
import { AdmittedFeed } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
25
25
|
import { createStorage, StorageType } from '@dxos/random-access-storage';
|
|
26
26
|
import { BlobStore } from '@dxos/teleport-extension-object-sync';
|
|
27
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
28
27
|
|
|
29
28
|
import { Identity } from './identity';
|
|
30
29
|
|
|
@@ -106,7 +105,7 @@ describe('identity/identity', () => {
|
|
|
106
105
|
});
|
|
107
106
|
|
|
108
107
|
await identity.open(new Context());
|
|
109
|
-
|
|
108
|
+
onTestFinished(() => identity.close(new Context()));
|
|
110
109
|
|
|
111
110
|
//
|
|
112
111
|
// Identity genesis
|
|
@@ -221,7 +220,7 @@ describe('identity/identity', () => {
|
|
|
221
220
|
}));
|
|
222
221
|
|
|
223
222
|
await identity.open(new Context());
|
|
224
|
-
|
|
223
|
+
onTestFinished(() => identity.close(new Context()));
|
|
225
224
|
|
|
226
225
|
//
|
|
227
226
|
// Identity genesis
|
|
@@ -314,7 +313,7 @@ describe('identity/identity', () => {
|
|
|
314
313
|
}));
|
|
315
314
|
|
|
316
315
|
await identity.open(new Context());
|
|
317
|
-
|
|
316
|
+
onTestFinished(() => identity.close(new Context()));
|
|
318
317
|
}
|
|
319
318
|
|
|
320
319
|
//
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test, onTestFinished } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncChain } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
-
import { describe, test, afterTest } from '@dxos/test';
|
|
12
11
|
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
14
13
|
import { createPeers, createServiceContext, performInvitation } from '../testing';
|
|
15
14
|
|
|
16
15
|
const closeAfterTest = async (peer: ServiceContext) => {
|
|
17
|
-
|
|
16
|
+
onTestFinished(async () => {
|
|
17
|
+
await peer.close();
|
|
18
|
+
});
|
|
18
19
|
return peer;
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -22,7 +23,9 @@ describe('services/device', () => {
|
|
|
22
23
|
test('creates identity', async () => {
|
|
23
24
|
const peer = await createServiceContext();
|
|
24
25
|
await peer.open(new Context());
|
|
25
|
-
|
|
26
|
+
onTestFinished(async () => {
|
|
27
|
+
await peer.close();
|
|
28
|
+
});
|
|
26
29
|
|
|
27
30
|
const identity = await peer.createIdentity();
|
|
28
31
|
expect(identity).not.to.be.undefined;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { beforeEach, onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { type PushStream, sleep, Trigger, waitForCondition } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
-
import {
|
|
11
|
+
import { openAndClose } from '@dxos/test-utils';
|
|
12
12
|
import { range } from '@dxos/util';
|
|
13
13
|
|
|
14
14
|
import { type InvitationProtocol } from './invitation-protocol';
|
|
@@ -34,6 +34,7 @@ type StateUpdateSink = PushStream<Invitation> & {
|
|
|
34
34
|
|
|
35
35
|
describe('InvitationHandler', () => {
|
|
36
36
|
let testBuilder: TestBuilder;
|
|
37
|
+
|
|
37
38
|
beforeEach(() => {
|
|
38
39
|
testBuilder = new TestBuilder();
|
|
39
40
|
});
|
|
@@ -163,7 +164,7 @@ describe('InvitationHandler', () => {
|
|
|
163
164
|
expect(guest.ctx.disposed).to.be.true;
|
|
164
165
|
});
|
|
165
166
|
|
|
166
|
-
test('guest gives up after trying with three hosts', async () => {
|
|
167
|
+
test('guest gives up after trying with three hosts', { timeout: 20_000 }, async () => {
|
|
167
168
|
const hosts: PeerSetup[] = [await createPeer()];
|
|
168
169
|
const [host] = hosts;
|
|
169
170
|
const invitation = await createInvitation(host, { multiUse: true });
|
|
@@ -181,7 +182,7 @@ describe('InvitationHandler', () => {
|
|
|
181
182
|
|
|
182
183
|
await sleep(10);
|
|
183
184
|
expect(guest.sink.lastState).to.eq(Invitation.State.ERROR);
|
|
184
|
-
})
|
|
185
|
+
});
|
|
185
186
|
|
|
186
187
|
test('single host - many guests', async () => {
|
|
187
188
|
const hosts: PeerSetup[] = [await createPeer()];
|
|
@@ -261,7 +262,9 @@ describe('InvitationHandler', () => {
|
|
|
261
262
|
});
|
|
262
263
|
const protocol = new SpaceInvitationProtocol(peer.dataSpaceManager, peer.identity, peer.keyring, spaceKey);
|
|
263
264
|
const ctx = new Context();
|
|
264
|
-
|
|
265
|
+
onTestFinished(async () => {
|
|
266
|
+
await ctx.dispose();
|
|
267
|
+
});
|
|
265
268
|
const sink = newStateUpdateSink();
|
|
266
269
|
return { ctx, sink, peer, protocol, handler: invitationHandler, spaceKey };
|
|
267
270
|
};
|
|
@@ -269,14 +272,18 @@ describe('InvitationHandler', () => {
|
|
|
269
272
|
const hostInvitation = async (setup: PeerSetup, invitation: Invitation) => {
|
|
270
273
|
await setup.ctx.dispose();
|
|
271
274
|
setup.ctx = new Context();
|
|
272
|
-
|
|
275
|
+
onTestFinished(async () => {
|
|
276
|
+
await setup.ctx.dispose();
|
|
277
|
+
});
|
|
273
278
|
setup.handler.handleInvitationFlow(setup.ctx, setup.sink, setup.protocol, invitation);
|
|
274
279
|
};
|
|
275
280
|
|
|
276
281
|
const acceptInvitation = async (setup: PeerSetup, invitation: Invitation): Promise<Trigger<string>> => {
|
|
277
282
|
await setup.ctx.dispose();
|
|
278
283
|
setup.ctx = new Context();
|
|
279
|
-
|
|
284
|
+
onTestFinished(async () => {
|
|
285
|
+
await setup.ctx.dispose();
|
|
286
|
+
});
|
|
280
287
|
const authCodeInput = new Trigger<string>();
|
|
281
288
|
setup.handler.acceptInvitation(setup.ctx, setup.sink, setup.protocol, invitation, authCodeInput);
|
|
282
289
|
return authCodeInput;
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncChain, Trigger } from '@dxos/async';
|
|
8
8
|
import { raise } from '@dxos/debug';
|
|
9
9
|
import { AlreadyJoinedError } from '@dxos/protocols';
|
|
10
10
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
11
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
12
11
|
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
14
13
|
import { createIdentity, createPeers } from '../testing';
|
|
15
14
|
import { acceptInvitation, createInvitation, performInvitation } from '../testing/invitation-utils';
|
|
16
15
|
|
|
17
16
|
const closeAfterTest = async (peer: ServiceContext) => {
|
|
18
|
-
|
|
17
|
+
onTestFinished(async () => {
|
|
18
|
+
await peer.close();
|
|
19
|
+
});
|
|
19
20
|
return peer;
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { log, LogLevel } from '@dxos/log';
|
|
9
9
|
import { type LogEntry } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
-
import { beforeEach, describe, test } from '@dxos/test';
|
|
11
10
|
|
|
12
11
|
import { LoggingServiceImpl } from './logging-service';
|
|
13
12
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Trigger } from '@dxos/async';
|
|
8
8
|
import { Context } from '@dxos/context';
|
|
9
9
|
import { type NetworkService, ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
11
10
|
|
|
12
11
|
import { NetworkServiceImpl } from './network-service';
|
|
13
12
|
import { type ServiceContext } from '../services';
|
|
@@ -41,7 +40,7 @@ describe('NetworkService', () => {
|
|
|
41
40
|
query.subscribe(({ swarm }) => {
|
|
42
41
|
result.wake(swarm);
|
|
43
42
|
});
|
|
44
|
-
|
|
43
|
+
onTestFinished(() => query.close());
|
|
45
44
|
expect(await result.wait()).to.equal(ConnectionState.ONLINE);
|
|
46
45
|
|
|
47
46
|
result = new Trigger<ConnectionState | undefined>();
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncTimeout } from '@dxos/async';
|
|
8
8
|
import { AutomergeContext } from '@dxos/echo-db';
|
|
9
9
|
import { AutomergeHost, DataServiceImpl } from '@dxos/echo-pipeline';
|
|
10
10
|
import { IndexMetadataStore } from '@dxos/indexing';
|
|
11
11
|
import { createTestLevel } from '@dxos/kv-store/testing';
|
|
12
|
-
import {
|
|
12
|
+
import { openAndClose } from '@dxos/test-utils';
|
|
13
13
|
|
|
14
14
|
describe('AutomergeHost', () => {
|
|
15
15
|
test('automerge context is being synced with host', async () => {
|
|
@@ -22,14 +22,16 @@ describe('AutomergeHost', () => {
|
|
|
22
22
|
|
|
23
23
|
const level = createTestLevel();
|
|
24
24
|
await level.open();
|
|
25
|
-
|
|
25
|
+
onTestFinished(() => level.close());
|
|
26
26
|
|
|
27
27
|
const host = new AutomergeHost({
|
|
28
28
|
db: level,
|
|
29
29
|
indexMetadataStore: new IndexMetadataStore({ db: level.sublevel('index-metadata') }),
|
|
30
30
|
});
|
|
31
31
|
await host.open();
|
|
32
|
-
|
|
32
|
+
onTestFinished(async () => {
|
|
33
|
+
await host.close();
|
|
34
|
+
});
|
|
33
35
|
|
|
34
36
|
const dataService = new DataServiceImpl({ automergeHost: host, updateIndexes: async () => {} });
|
|
35
37
|
const client = new AutomergeContext(dataService);
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
5
7
|
import { MemorySignalManagerContext, MemorySignalManager } from '@dxos/messaging';
|
|
6
8
|
import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
7
|
-
import {
|
|
9
|
+
import { openAndClose } from '@dxos/test-utils';
|
|
8
10
|
|
|
9
11
|
import { createServiceContext, performInvitation } from '../testing';
|
|
10
12
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import chai, { expect } from 'chai';
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
7
5
|
import { rmSync } from 'node:fs';
|
|
6
|
+
import { afterEach, onTestFinished, describe, expect, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { asyncTimeout, latch, Trigger } from '@dxos/async';
|
|
10
9
|
import { Config } from '@dxos/config';
|
|
@@ -14,13 +13,10 @@ import { type PublicKey } from '@dxos/keys';
|
|
|
14
13
|
import { MemorySignalManagerContext } from '@dxos/messaging';
|
|
15
14
|
import { type Identity } from '@dxos/protocols/proto/dxos/client/services';
|
|
16
15
|
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
17
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
18
16
|
import { isNode } from '@dxos/util';
|
|
19
17
|
|
|
20
18
|
import { createMockCredential, createServiceHost } from '../testing';
|
|
21
19
|
|
|
22
|
-
chai.use(chaiAsPromised);
|
|
23
|
-
|
|
24
20
|
describe('ClientServicesHost', () => {
|
|
25
21
|
const dataRoot = '/tmp/dxos/client-services/service-host/storage';
|
|
26
22
|
|
|
@@ -38,7 +34,7 @@ describe('ClientServicesHost', () => {
|
|
|
38
34
|
test('queryCredentials', async () => {
|
|
39
35
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
40
36
|
await host.open(new Context());
|
|
41
|
-
|
|
37
|
+
onTestFinished(() => host.close());
|
|
42
38
|
|
|
43
39
|
await host.services.IdentityService!.createIdentity({});
|
|
44
40
|
const { spaceKey } = await host.services.SpacesService!.createSpace();
|
|
@@ -49,7 +45,7 @@ describe('ClientServicesHost', () => {
|
|
|
49
45
|
tick();
|
|
50
46
|
// console.log(credential);
|
|
51
47
|
});
|
|
52
|
-
|
|
48
|
+
onTestFinished(() => stream.close());
|
|
53
49
|
|
|
54
50
|
await done();
|
|
55
51
|
});
|
|
@@ -57,7 +53,7 @@ describe('ClientServicesHost', () => {
|
|
|
57
53
|
test('write and query credentials', async () => {
|
|
58
54
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
59
55
|
await host.open(new Context());
|
|
60
|
-
|
|
56
|
+
onTestFinished(() => host.close());
|
|
61
57
|
|
|
62
58
|
await host.services.IdentityService!.createIdentity({});
|
|
63
59
|
|
|
@@ -86,7 +82,7 @@ describe('ClientServicesHost', () => {
|
|
|
86
82
|
queriedCredential.wake(credential);
|
|
87
83
|
}
|
|
88
84
|
});
|
|
89
|
-
|
|
85
|
+
onTestFinished(() => credentials.close());
|
|
90
86
|
|
|
91
87
|
await queriedCredential.wait();
|
|
92
88
|
});
|
|
@@ -94,7 +90,7 @@ describe('ClientServicesHost', () => {
|
|
|
94
90
|
test('sign presentation', async () => {
|
|
95
91
|
const host = createServiceHost(new Config(), new MemorySignalManagerContext());
|
|
96
92
|
await host.open(new Context());
|
|
97
|
-
|
|
93
|
+
onTestFinished(() => host.close());
|
|
98
94
|
|
|
99
95
|
await host.services.IdentityService!.createIdentity({});
|
|
100
96
|
|
|
@@ -147,9 +143,9 @@ describe('ClientServicesHost', () => {
|
|
|
147
143
|
trigger.wake(identity.identity);
|
|
148
144
|
}
|
|
149
145
|
});
|
|
150
|
-
await expect(asyncTimeout(trigger.wait(), 200)).
|
|
146
|
+
await expect(asyncTimeout(trigger.wait(), 200)).rejects.toBeInstanceOf(Error);
|
|
151
147
|
await stream?.close();
|
|
152
148
|
await host.close();
|
|
153
149
|
}
|
|
154
|
-
})
|
|
150
|
+
});
|
|
155
151
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Event } from '@dxos/async';
|
|
8
8
|
import { type ClientServices } from '@dxos/client-protocol';
|
|
@@ -12,7 +12,6 @@ import { log } from '@dxos/log';
|
|
|
12
12
|
import { schema } from '@dxos/protocols/proto';
|
|
13
13
|
import { type SystemService, SystemStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
14
14
|
import { createLinkedPorts, createProtoRpcPeer, createServiceBundle } from '@dxos/rpc';
|
|
15
|
-
import { describe, test } from '@dxos/test';
|
|
16
15
|
|
|
17
16
|
import { ServiceRegistry } from './service-registry';
|
|
18
17
|
import { SystemServiceImpl } from '../system';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { asyncTimeout, latch } from '@dxos/async';
|
|
8
8
|
import { createAdmissionCredentials } from '@dxos/credentials';
|
|
@@ -10,7 +10,7 @@ import { AuthStatus } from '@dxos/echo-pipeline';
|
|
|
10
10
|
import { writeMessages } from '@dxos/feed-store';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
13
|
-
import {
|
|
13
|
+
import { openAndClose } from '@dxos/test-utils';
|
|
14
14
|
|
|
15
15
|
import { TestBuilder, type TestPeer } from '../testing';
|
|
16
16
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { onTestFinished, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Context } from '@dxos/context';
|
|
8
8
|
import { CredentialGenerator } from '@dxos/credentials';
|
|
@@ -11,7 +11,6 @@ import { Keyring } from '@dxos/keyring';
|
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { AdmittedFeed, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
13
13
|
import { TestBuilder, type TestConnection, TestPeer } from '@dxos/teleport/testing';
|
|
14
|
-
import { afterTest, describe, test } from '@dxos/test';
|
|
15
14
|
|
|
16
15
|
import { NotarizationPlugin } from './notarization-plugin';
|
|
17
16
|
|
|
@@ -49,7 +48,7 @@ class TestAgent extends TestPeer {
|
|
|
49
48
|
describe('NotarizationPlugin', () => {
|
|
50
49
|
test('notarize single credential', async () => {
|
|
51
50
|
const testBuilder = new TestBuilder();
|
|
52
|
-
|
|
51
|
+
onTestFinished(() => testBuilder.destroy());
|
|
53
52
|
|
|
54
53
|
// peer0 is there to test retries.
|
|
55
54
|
const [_peer0, peer1, peer2] = await testBuilder.createPeers({ factory: () => new TestAgent() });
|
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
5
|
+
import { afterEach, onTestFinished, beforeEach, describe, expect, test } from 'vitest';
|
|
7
6
|
|
|
8
7
|
import { Trigger } from '@dxos/async';
|
|
9
8
|
import { Context } from '@dxos/context';
|
|
10
9
|
import { PublicKey } from '@dxos/keys';
|
|
11
10
|
import { type Space, type SpacesService } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
|
-
import { afterEach, afterTest, beforeEach, describe, test } from '@dxos/test';
|
|
13
11
|
|
|
14
12
|
import { SpacesServiceImpl } from './spaces-service';
|
|
15
13
|
import { type ServiceContext } from '../services';
|
|
16
14
|
import { createServiceContext } from '../testing';
|
|
17
15
|
|
|
18
|
-
chai.use(chaiAsPromised);
|
|
19
|
-
|
|
20
16
|
describe('SpacesService', () => {
|
|
21
17
|
let serviceContext: ServiceContext;
|
|
22
18
|
let spacesService: SpacesService;
|
|
@@ -36,7 +32,7 @@ describe('SpacesService', () => {
|
|
|
36
32
|
|
|
37
33
|
describe('createSpace', () => {
|
|
38
34
|
test('fails if no identity is available', async () => {
|
|
39
|
-
await expect(spacesService.createSpace()).
|
|
35
|
+
await expect(spacesService.createSpace()).rejects.toBeInstanceOf(Error);
|
|
40
36
|
});
|
|
41
37
|
|
|
42
38
|
test('creates a new space', async () => {
|
|
@@ -56,7 +52,7 @@ describe('SpacesService', () => {
|
|
|
56
52
|
query.subscribe(({ spaces }) => {
|
|
57
53
|
result.wake(spaces);
|
|
58
54
|
});
|
|
59
|
-
|
|
55
|
+
onTestFinished(() => query.close());
|
|
60
56
|
expect(await result.wait()).to.be.length(0);
|
|
61
57
|
});
|
|
62
58
|
|
|
@@ -73,7 +69,7 @@ describe('SpacesService', () => {
|
|
|
73
69
|
query.subscribe(({ spaces }) => {
|
|
74
70
|
result.wake(spaces);
|
|
75
71
|
});
|
|
76
|
-
|
|
72
|
+
onTestFinished(() => query.close());
|
|
77
73
|
|
|
78
74
|
const spaces = await result.wait();
|
|
79
75
|
expect(spaces).to.be.length(3);
|
|
@@ -87,7 +83,7 @@ describe('SpacesService', () => {
|
|
|
87
83
|
query.subscribe(({ spaces }) => {
|
|
88
84
|
result.wake(spaces);
|
|
89
85
|
});
|
|
90
|
-
|
|
86
|
+
onTestFinished(() => query.close());
|
|
91
87
|
expect(await result.wait()).to.be.length(0);
|
|
92
88
|
|
|
93
89
|
result.reset();
|
|
@@ -14,7 +14,6 @@ import { getRootPath } from './util';
|
|
|
14
14
|
// TODO(burdon): Factor out.
|
|
15
15
|
export const createStorageObjects = (config: Runtime.Client.Storage) => {
|
|
16
16
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
17
|
-
|
|
18
17
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
19
18
|
throw new InvalidConfigError('RAM storage cannot be used in persistent mode.');
|
|
20
19
|
}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { expect } from '
|
|
5
|
+
import { beforeEach, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Event, Trigger } from '@dxos/async';
|
|
8
8
|
import { Config } from '@dxos/config';
|
|
9
9
|
import { type SystemService, SystemStatus, type QueryStatusResponse } from '@dxos/protocols/proto/dxos/client/services';
|
|
10
|
-
import { beforeEach, describe, test } from '@dxos/test';
|
|
11
10
|
|
|
12
11
|
import { SystemServiceImpl } from './system-service';
|
|
13
12
|
|