@fluidframework/register-collection 2.0.0-dev-rc.2.0.0.246488 → 2.0.0-dev-rc.3.0.0.253463
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/api-report/register-collection.api.md +1 -1
- package/dist/consensusRegisterCollection.d.ts +2 -1
- package/dist/consensusRegisterCollection.d.ts.map +1 -1
- package/dist/consensusRegisterCollection.js +11 -11
- package/dist/consensusRegisterCollection.js.map +1 -1
- package/dist/consensusRegisterCollectionFactory.d.ts +1 -1
- package/dist/consensusRegisterCollectionFactory.d.ts.map +1 -1
- package/dist/consensusRegisterCollectionFactory.js.map +1 -1
- package/dist/interfaces.d.ts +1 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/register-collection-alpha.d.ts +1 -1
- package/dist/register-collection-beta.d.ts +1 -1
- package/dist/register-collection-public.d.ts +1 -1
- package/dist/register-collection-untrimmed.d.ts +1 -1
- package/lib/consensusRegisterCollection.d.ts +2 -1
- package/lib/consensusRegisterCollection.d.ts.map +1 -1
- package/lib/consensusRegisterCollection.js +2 -2
- package/lib/consensusRegisterCollection.js.map +1 -1
- package/lib/consensusRegisterCollectionFactory.d.ts +1 -1
- package/lib/consensusRegisterCollectionFactory.d.ts.map +1 -1
- package/lib/consensusRegisterCollectionFactory.js.map +1 -1
- package/lib/interfaces.d.ts +1 -1
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/register-collection-alpha.d.ts +1 -1
- package/lib/register-collection-beta.d.ts +1 -1
- package/lib/register-collection-public.d.ts +1 -1
- package/lib/register-collection-untrimmed.d.ts +1 -1
- package/lib/tsdoc-metadata.json +11 -0
- package/package.json +18 -27
- package/src/consensusRegisterCollection.ts +4 -6
- package/src/consensusRegisterCollectionFactory.ts +2 -1
- package/src/interfaces.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/lib/test/consensusRegisterCollection.spec.js +0 -281
- package/lib/test/consensusRegisterCollection.spec.js.map +0 -1
- package/lib/test/types/validateRegisterCollectionPrevious.generated.js +0 -14
- package/lib/test/types/validateRegisterCollectionPrevious.generated.js.map +0 -1
|
@@ -8,7 +8,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
|
|
|
8
8
|
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
9
|
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
10
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
11
|
+
import { SharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* {@inheritDoc IConsensusRegisterCollection}
|
|
@@ -8,7 +8,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
|
|
|
8
8
|
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
9
|
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
10
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
11
|
+
import { SharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
12
|
|
|
13
13
|
/* Excluded from this release type: ConsensusRegisterCollection */
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
|
|
|
8
8
|
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
9
|
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
10
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
11
|
+
import { SharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
12
|
|
|
13
13
|
/* Excluded from this release type: ConsensusRegisterCollection */
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions'
|
|
|
8
8
|
import { ISharedObject } from '@fluidframework/shared-object-base';
|
|
9
9
|
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
|
|
10
10
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
11
|
-
import { SharedObject } from '@fluidframework/shared-object-base';
|
|
11
|
+
import { SharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* {@inheritDoc IConsensusRegisterCollection}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.42.3"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/register-collection",
|
|
3
|
-
"version": "2.0.0-dev-rc.
|
|
3
|
+
"version": "2.0.0-dev-rc.3.0.0.253463",
|
|
4
4
|
"description": "Consensus Register",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,16 +14,6 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"import": {
|
|
18
|
-
"types": "./lib/index.d.ts",
|
|
19
|
-
"default": "./lib/index.js"
|
|
20
|
-
},
|
|
21
|
-
"require": {
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"./public": {
|
|
27
17
|
"import": {
|
|
28
18
|
"types": "./lib/register-collection-public.d.ts",
|
|
29
19
|
"default": "./lib/index.js"
|
|
@@ -77,25 +67,26 @@
|
|
|
77
67
|
"temp-directory": "nyc/.nyc_output"
|
|
78
68
|
},
|
|
79
69
|
"dependencies": {
|
|
80
|
-
"@fluid-internal/client-utils": "2.0.0-dev-rc.
|
|
81
|
-
"@fluidframework/core-interfaces": "2.0.0-dev-rc.
|
|
82
|
-
"@fluidframework/core-utils": "2.0.0-dev-rc.
|
|
83
|
-
"@fluidframework/datastore-definitions": "2.0.0-dev-rc.
|
|
84
|
-
"@fluidframework/driver-utils": "2.0.0-dev-rc.
|
|
70
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.3.0.0.253463",
|
|
71
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.253463",
|
|
72
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.3.0.0.253463",
|
|
73
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev-rc.3.0.0.253463",
|
|
74
|
+
"@fluidframework/driver-utils": "2.0.0-dev-rc.3.0.0.253463",
|
|
85
75
|
"@fluidframework/protocol-definitions": "^3.2.0",
|
|
86
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.
|
|
87
|
-
"@fluidframework/shared-object-base": "2.0.0-dev-rc.
|
|
76
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.3.0.0.253463",
|
|
77
|
+
"@fluidframework/shared-object-base": "2.0.0-dev-rc.3.0.0.253463"
|
|
88
78
|
},
|
|
89
79
|
"devDependencies": {
|
|
90
|
-
"@arethetypeswrong/cli": "^0.
|
|
91
|
-
"@
|
|
92
|
-
"@fluid-
|
|
80
|
+
"@arethetypeswrong/cli": "^0.15.2",
|
|
81
|
+
"@biomejs/biome": "^1.6.2",
|
|
82
|
+
"@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.253463",
|
|
83
|
+
"@fluid-private/test-dds-utils": "2.0.0-dev-rc.3.0.0.253463",
|
|
93
84
|
"@fluid-tools/build-cli": "^0.34.0",
|
|
94
85
|
"@fluidframework/build-common": "^2.0.3",
|
|
95
86
|
"@fluidframework/build-tools": "^0.34.0",
|
|
96
87
|
"@fluidframework/eslint-config-fluid": "^5.1.0",
|
|
97
88
|
"@fluidframework/register-collection-previous": "npm:@fluidframework/register-collection@2.0.0-internal.8.0.0",
|
|
98
|
-
"@fluidframework/test-runtime-utils": "2.0.0-dev-rc.
|
|
89
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev-rc.3.0.0.253463",
|
|
99
90
|
"@microsoft/api-extractor": "^7.42.3",
|
|
100
91
|
"@types/mocha": "^9.1.1",
|
|
101
92
|
"@types/node": "^18.19.0",
|
|
@@ -141,16 +132,16 @@
|
|
|
141
132
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
142
133
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
143
134
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
135
|
+
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
144
136
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
145
137
|
"ci:build:docs": "api-extractor run",
|
|
146
138
|
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
147
139
|
"eslint": "eslint --format stylish src",
|
|
148
140
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
149
|
-
"format": "
|
|
150
|
-
"
|
|
151
|
-
"lint
|
|
152
|
-
"
|
|
153
|
-
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
141
|
+
"format": "fluid-build --task format .",
|
|
142
|
+
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
143
|
+
"lint": "fluid-build . --task lint",
|
|
144
|
+
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
154
145
|
"test": "npm run test:mocha",
|
|
155
146
|
"test:coverage": "c8 npm test",
|
|
156
147
|
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { bufferToString } from "@fluid-internal/client-utils";
|
|
7
|
-
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
7
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import {
|
|
9
9
|
IChannelAttributes,
|
|
10
10
|
IChannelStorageService,
|
|
@@ -12,11 +12,9 @@ import {
|
|
|
12
12
|
} from "@fluidframework/datastore-definitions";
|
|
13
13
|
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
|
|
14
14
|
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
createSingleBlobSummary,
|
|
19
|
-
} from "@fluidframework/shared-object-base";
|
|
15
|
+
import { IFluidSerializer } from "@fluidframework/shared-object-base";
|
|
16
|
+
import { SharedObject, createSingleBlobSummary } from "@fluidframework/shared-object-base/internal";
|
|
17
|
+
|
|
20
18
|
import { ConsensusRegisterCollectionFactory } from "./consensusRegisterCollectionFactory.js";
|
|
21
19
|
import {
|
|
22
20
|
IConsensusRegisterCollection,
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
IChannelAttributes,
|
|
8
|
-
IFluidDataStoreRuntime,
|
|
9
8
|
IChannelServices,
|
|
9
|
+
IFluidDataStoreRuntime,
|
|
10
10
|
} from "@fluidframework/datastore-definitions";
|
|
11
|
+
|
|
11
12
|
import { ConsensusRegisterCollection } from "./consensusRegisterCollection.js";
|
|
12
13
|
import { IConsensusRegisterCollection, IConsensusRegisterCollectionFactory } from "./interfaces.js";
|
|
13
14
|
import { pkgVersion } from "./packageVersion.js";
|
package/src/interfaces.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
IFluidDataStoreRuntime,
|
|
8
|
-
IChannelServices,
|
|
9
7
|
IChannelAttributes,
|
|
10
8
|
IChannelFactory,
|
|
9
|
+
IChannelServices,
|
|
10
|
+
IFluidDataStoreRuntime,
|
|
11
11
|
} from "@fluidframework/datastore-definitions";
|
|
12
12
|
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
13
13
|
|
package/src/packageVersion.ts
CHANGED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { strict as assert } from "assert";
|
|
6
|
-
import { BlobTreeEntry } from "@fluidframework/driver-utils";
|
|
7
|
-
import { runGCTests } from "@fluid-private/test-dds-utils";
|
|
8
|
-
import { MockContainerRuntimeFactory, MockContainerRuntimeFactoryForReconnection, MockEmptyDeltaConnection, MockFluidDataStoreRuntime, MockStorage, } from "@fluidframework/test-runtime-utils";
|
|
9
|
-
import { ConsensusRegisterCollectionFactory } from "../consensusRegisterCollectionFactory.js";
|
|
10
|
-
function createConnectedCollection(id, runtimeFactory) {
|
|
11
|
-
const dataStoreRuntime = new MockFluidDataStoreRuntime();
|
|
12
|
-
runtimeFactory.createContainerRuntime(dataStoreRuntime);
|
|
13
|
-
const services = {
|
|
14
|
-
deltaConnection: dataStoreRuntime.createDeltaConnection(),
|
|
15
|
-
objectStorage: new MockStorage(),
|
|
16
|
-
};
|
|
17
|
-
const crcFactory = new ConsensusRegisterCollectionFactory();
|
|
18
|
-
const collection = crcFactory.create(dataStoreRuntime, id);
|
|
19
|
-
collection.connect(services);
|
|
20
|
-
return collection;
|
|
21
|
-
}
|
|
22
|
-
function createLocalCollection(id) {
|
|
23
|
-
const factory = new ConsensusRegisterCollectionFactory();
|
|
24
|
-
return factory.create(new MockFluidDataStoreRuntime(), id);
|
|
25
|
-
}
|
|
26
|
-
function createCollectionForReconnection(id, runtimeFactory) {
|
|
27
|
-
const dataStoreRuntime = new MockFluidDataStoreRuntime();
|
|
28
|
-
const containerRuntime = runtimeFactory.createContainerRuntime(dataStoreRuntime);
|
|
29
|
-
const services = {
|
|
30
|
-
deltaConnection: dataStoreRuntime.createDeltaConnection(),
|
|
31
|
-
objectStorage: new MockStorage(),
|
|
32
|
-
};
|
|
33
|
-
const crcFactory = new ConsensusRegisterCollectionFactory();
|
|
34
|
-
const collection = crcFactory.create(dataStoreRuntime, id);
|
|
35
|
-
collection.connect(services);
|
|
36
|
-
return { collection, containerRuntime };
|
|
37
|
-
}
|
|
38
|
-
describe("ConsensusRegisterCollection", () => {
|
|
39
|
-
describe("Single connected client", () => {
|
|
40
|
-
const collectionId = "consensus-register-collection";
|
|
41
|
-
let crc;
|
|
42
|
-
let containerRuntimeFactory;
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
containerRuntimeFactory = new MockContainerRuntimeFactory();
|
|
45
|
-
crc = createConnectedCollection(collectionId, containerRuntimeFactory);
|
|
46
|
-
});
|
|
47
|
-
async function writeAndProcessMsg(key, value) {
|
|
48
|
-
const waitP = crc.write(key, value);
|
|
49
|
-
containerRuntimeFactory.processAllMessages();
|
|
50
|
-
return waitP;
|
|
51
|
-
}
|
|
52
|
-
describe("API", () => {
|
|
53
|
-
it("Can create a collection", () => {
|
|
54
|
-
assert.ok(crc);
|
|
55
|
-
});
|
|
56
|
-
it("Can add and remove data", async () => {
|
|
57
|
-
assert.strictEqual(crc.read("key1"), undefined);
|
|
58
|
-
const writeResult = await writeAndProcessMsg("key1", "val1");
|
|
59
|
-
assert.strictEqual(crc.read("key1"), "val1");
|
|
60
|
-
assert.strictEqual(writeResult, true, "No concurrency expected");
|
|
61
|
-
});
|
|
62
|
-
it("Can add and remove a handle", async () => {
|
|
63
|
-
assert.strictEqual(crc.read("key1"), undefined);
|
|
64
|
-
const handle = crc.handle;
|
|
65
|
-
if (handle === undefined) {
|
|
66
|
-
assert.fail("Need an actual handle to test this case");
|
|
67
|
-
}
|
|
68
|
-
const writeResult = await writeAndProcessMsg("key1", handle);
|
|
69
|
-
const readValue = crc.read("key1");
|
|
70
|
-
assert.strictEqual(readValue.absolutePath, handle.absolutePath);
|
|
71
|
-
assert.strictEqual(writeResult, true, "No concurrency expected");
|
|
72
|
-
});
|
|
73
|
-
it("Change events emit the right key/value", async () => {
|
|
74
|
-
crc.on("atomicChanged", (key, value, local) => {
|
|
75
|
-
assert.strictEqual(key, "key1", "atomicChanged event emitted the wrong key");
|
|
76
|
-
assert.strictEqual(value, "val1", "atomicChanged event emitted the wrong value");
|
|
77
|
-
});
|
|
78
|
-
crc.on("versionChanged", (key, value, local) => {
|
|
79
|
-
assert.strictEqual(key, "key1", "versionChanged event emitted the wrong key");
|
|
80
|
-
assert.strictEqual(value, "val1", "versionChanged event emitted the wrong value");
|
|
81
|
-
});
|
|
82
|
-
await writeAndProcessMsg("key1", "val1");
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe("Summary", () => {
|
|
86
|
-
const snapshotFileName = "header";
|
|
87
|
-
const expectedSerialization = JSON.stringify({
|
|
88
|
-
key1: {
|
|
89
|
-
atomic: { sequenceNumber: 1, value: { type: "Plain", value: "val1.1" } },
|
|
90
|
-
versions: [{ sequenceNumber: 1, value: { type: "Plain", value: "val1.1" } }],
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
const legacySharedObjectSerialization = JSON.stringify({
|
|
94
|
-
key1: {
|
|
95
|
-
atomic: { sequenceNumber: 1, value: { type: "Shared", value: "sharedObjId" } },
|
|
96
|
-
versions: [
|
|
97
|
-
{ sequenceNumber: 1, value: { type: "Shared", value: "sharedObjId" } },
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
const buildTree = (serialized) => ({
|
|
102
|
-
entries: [new BlobTreeEntry(snapshotFileName, serialized)],
|
|
103
|
-
});
|
|
104
|
-
it("summarize", async () => {
|
|
105
|
-
await writeAndProcessMsg("key1", "val1.1");
|
|
106
|
-
const summaryTree = crc.getAttachSummary().summary;
|
|
107
|
-
assert(Object.keys(summaryTree.tree).length === 1, "summarize should return a tree with single blob");
|
|
108
|
-
const serialized = summaryTree.tree.header?.content;
|
|
109
|
-
assert(serialized, "summarize should return a tree with blob with contents");
|
|
110
|
-
assert.strictEqual(serialized, expectedSerialization);
|
|
111
|
-
});
|
|
112
|
-
it("load", async () => {
|
|
113
|
-
const tree = buildTree(expectedSerialization);
|
|
114
|
-
const services = {
|
|
115
|
-
deltaConnection: new MockEmptyDeltaConnection(),
|
|
116
|
-
objectStorage: new MockStorage(tree),
|
|
117
|
-
};
|
|
118
|
-
const crcFactory = new ConsensusRegisterCollectionFactory();
|
|
119
|
-
const loadedCrc = await crcFactory.load(new MockFluidDataStoreRuntime(), collectionId, services, ConsensusRegisterCollectionFactory.Attributes);
|
|
120
|
-
assert.strictEqual(loadedCrc.read("key1"), "val1.1");
|
|
121
|
-
});
|
|
122
|
-
it("load with SharedObject not supported", async () => {
|
|
123
|
-
const tree = buildTree(legacySharedObjectSerialization);
|
|
124
|
-
const services = {
|
|
125
|
-
deltaConnection: new MockEmptyDeltaConnection(),
|
|
126
|
-
objectStorage: new MockStorage(tree),
|
|
127
|
-
};
|
|
128
|
-
const crcFactory = new ConsensusRegisterCollectionFactory();
|
|
129
|
-
await assert.rejects(crcFactory.load(new MockFluidDataStoreRuntime(), collectionId, services, ConsensusRegisterCollectionFactory.Attributes), "SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized");
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
describe("Multiple Clients", () => {
|
|
134
|
-
describe("Local state", () => {
|
|
135
|
-
let containerRuntimeFactory;
|
|
136
|
-
let testCollection1;
|
|
137
|
-
let testCollection2;
|
|
138
|
-
beforeEach(() => {
|
|
139
|
-
containerRuntimeFactory = new MockContainerRuntimeFactoryForReconnection();
|
|
140
|
-
testCollection1 = createLocalCollection("collection1");
|
|
141
|
-
testCollection2 = createLocalCollection("collection2");
|
|
142
|
-
});
|
|
143
|
-
it("should not send ops when the collection is not connected", async () => {
|
|
144
|
-
// Add a listener to the second collection. This is used to verify that the written value reaches
|
|
145
|
-
// the remote client.
|
|
146
|
-
let receivedValue = "";
|
|
147
|
-
testCollection2.on("atomicChanged", (key, value) => {
|
|
148
|
-
receivedValue = value;
|
|
149
|
-
});
|
|
150
|
-
// Write to the first register collection.
|
|
151
|
-
const testValue = "testValue";
|
|
152
|
-
const writeP = testCollection1.write("key", testValue);
|
|
153
|
-
// Process the messages.
|
|
154
|
-
containerRuntimeFactory.processAllMessages();
|
|
155
|
-
// Verify that the first collection successfully writes and is the winner.
|
|
156
|
-
const winner = await writeP;
|
|
157
|
-
assert.equal(winner, true, "Write was not successful");
|
|
158
|
-
// Verify that the remote client does not get this write because the DDS is not connected.
|
|
159
|
-
assert.equal(receivedValue, "", "The remote client should not have received the write");
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
describe("Reconnection", () => {
|
|
163
|
-
const testKey = "testKey";
|
|
164
|
-
const testValue = "testValue";
|
|
165
|
-
let receivedKey = "";
|
|
166
|
-
let receivedValue = "";
|
|
167
|
-
let receivedLocalStatus = true;
|
|
168
|
-
let containerRuntimeFactory;
|
|
169
|
-
let containerRuntime1;
|
|
170
|
-
let testCollection1;
|
|
171
|
-
let testCollection2;
|
|
172
|
-
beforeEach(() => {
|
|
173
|
-
containerRuntimeFactory = new MockContainerRuntimeFactoryForReconnection();
|
|
174
|
-
const response1 = createCollectionForReconnection("collection1", containerRuntimeFactory);
|
|
175
|
-
testCollection1 = response1.collection;
|
|
176
|
-
containerRuntime1 = response1.containerRuntime;
|
|
177
|
-
const response2 = createCollectionForReconnection("collection2", containerRuntimeFactory);
|
|
178
|
-
testCollection2 = response2.collection;
|
|
179
|
-
// Add a listener to the second collection. This is used to verify that the written value reaches
|
|
180
|
-
// the remote client.
|
|
181
|
-
testCollection2.on("atomicChanged", (key, value, local) => {
|
|
182
|
-
receivedKey = key;
|
|
183
|
-
receivedValue = value;
|
|
184
|
-
receivedLocalStatus = local;
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
it("can resend unacked ops on reconnection", async () => {
|
|
188
|
-
// Write to the first register collection.
|
|
189
|
-
const writeP = testCollection1.write(testKey, testValue);
|
|
190
|
-
// Disconnect and reconnect the first collection.
|
|
191
|
-
containerRuntime1.connected = false;
|
|
192
|
-
containerRuntime1.connected = true;
|
|
193
|
-
// Process the messages.
|
|
194
|
-
containerRuntimeFactory.processAllMessages();
|
|
195
|
-
// Verify that the first collection successfully writes and is the winner.
|
|
196
|
-
const winner = await writeP;
|
|
197
|
-
assert.equal(winner, true, "Write was not successful");
|
|
198
|
-
// Verify that the remote register collection received the write.
|
|
199
|
-
assert.equal(receivedKey, testKey, "The remote client did not receive the key");
|
|
200
|
-
assert.equal(receivedValue, testValue, "The remote client did not receive the value");
|
|
201
|
-
assert.equal(receivedLocalStatus, false, "The remote client's value should not be local");
|
|
202
|
-
});
|
|
203
|
-
it("can store ops in disconnected state and resend them on reconnection", async () => {
|
|
204
|
-
// Disconnect the first collection.
|
|
205
|
-
containerRuntime1.connected = false;
|
|
206
|
-
// Write to the first register collection.
|
|
207
|
-
const writeP = testCollection1.write(testKey, testValue);
|
|
208
|
-
// Reconnect the first collection.
|
|
209
|
-
containerRuntime1.connected = true;
|
|
210
|
-
// Process the messages.
|
|
211
|
-
containerRuntimeFactory.processAllMessages();
|
|
212
|
-
// Verify that the first collection successfully writes and is the winner.
|
|
213
|
-
const winner = await writeP;
|
|
214
|
-
assert.equal(winner, true, "Write was not successful");
|
|
215
|
-
// Verify that the remote register collection received the write.
|
|
216
|
-
assert.equal(receivedKey, testKey, "The remote client did not receive the key");
|
|
217
|
-
assert.equal(receivedValue, testValue, "The remote client did not receive the value");
|
|
218
|
-
assert.equal(receivedLocalStatus, false, "The remote client's value should not be local");
|
|
219
|
-
});
|
|
220
|
-
afterEach(() => {
|
|
221
|
-
receivedKey = "";
|
|
222
|
-
receivedValue = "";
|
|
223
|
-
receivedLocalStatus = true;
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
describe("Garbage Collection", () => {
|
|
228
|
-
class GCRegisteredCollectionProvider {
|
|
229
|
-
constructor() {
|
|
230
|
-
this.subCollectionCount = 0;
|
|
231
|
-
this._expectedRoutes = [];
|
|
232
|
-
this.containerRuntimeFactory = new MockContainerRuntimeFactory();
|
|
233
|
-
this.collection1 = createConnectedCollection("collection1", this.containerRuntimeFactory);
|
|
234
|
-
this.collection2 = createConnectedCollection("collection2", this.containerRuntimeFactory);
|
|
235
|
-
}
|
|
236
|
-
async writeAndProcessMsg(key, value) {
|
|
237
|
-
const waitP = this.collection1.write(key, value);
|
|
238
|
-
this.containerRuntimeFactory.processAllMessages();
|
|
239
|
-
return waitP;
|
|
240
|
-
}
|
|
241
|
-
get sharedObject() {
|
|
242
|
-
// Return the remote collection because we want to verify its summary data.
|
|
243
|
-
return this.collection2;
|
|
244
|
-
}
|
|
245
|
-
get expectedOutboundRoutes() {
|
|
246
|
-
return this._expectedRoutes;
|
|
247
|
-
}
|
|
248
|
-
async addOutboundRoutes() {
|
|
249
|
-
const subCollectionId = `subCollection-${++this.subCollectionCount}`;
|
|
250
|
-
const subTestCollection = createLocalCollection(subCollectionId);
|
|
251
|
-
await this.writeAndProcessMsg(subCollectionId, subTestCollection.handle);
|
|
252
|
-
this._expectedRoutes.push(subTestCollection.handle.absolutePath);
|
|
253
|
-
}
|
|
254
|
-
async deleteOutboundRoutes() {
|
|
255
|
-
const subCollectionId = `subCollection-${this.subCollectionCount}`;
|
|
256
|
-
const deletedHandle = this.collection1.read(subCollectionId);
|
|
257
|
-
assert(deletedHandle, "Route must be added before deleting");
|
|
258
|
-
// Delete the last handle that was added.
|
|
259
|
-
await this.writeAndProcessMsg(subCollectionId, "nonHandleValue");
|
|
260
|
-
// Remove deleted handle's route from expected routes.
|
|
261
|
-
this._expectedRoutes = this._expectedRoutes.filter((route) => route !== deletedHandle.absolutePath);
|
|
262
|
-
}
|
|
263
|
-
async addNestedHandles() {
|
|
264
|
-
const subCollectionId1 = `subCollection-${++this.subCollectionCount}`;
|
|
265
|
-
const subCollectionId2 = `subCollection-${++this.subCollectionCount}`;
|
|
266
|
-
const subTestCollection1 = createLocalCollection(subCollectionId1);
|
|
267
|
-
const subTestCollection2 = createLocalCollection(subCollectionId2);
|
|
268
|
-
const containingObject = {
|
|
269
|
-
collection1Handle: subTestCollection1.handle,
|
|
270
|
-
nestedObj: {
|
|
271
|
-
collection2Handle: subTestCollection2.handle,
|
|
272
|
-
},
|
|
273
|
-
};
|
|
274
|
-
await this.writeAndProcessMsg(subCollectionId2, containingObject);
|
|
275
|
-
this._expectedRoutes.push(subTestCollection1.handle.absolutePath, subTestCollection2.handle.absolutePath);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
runGCTests(GCRegisteredCollectionProvider);
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
//# sourceMappingURL=consensusRegisterCollection.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consensusRegisterCollection.spec.js","sourceRoot":"","sources":["../../src/test/consensusRegisterCollection.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAmB,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EACN,2BAA2B,EAC3B,0CAA0C,E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CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { BlobTreeEntry } from \"@fluidframework/driver-utils\";\nimport { ISummaryBlob, ITree } from \"@fluidframework/protocol-definitions\";\nimport { IGCTestProvider, runGCTests } from \"@fluid-private/test-dds-utils\";\nimport {\n\tMockContainerRuntimeFactory,\n\tMockContainerRuntimeFactoryForReconnection,\n\tMockContainerRuntimeForReconnection,\n\tMockEmptyDeltaConnection,\n\tMockFluidDataStoreRuntime,\n\tMockStorage,\n} from \"@fluidframework/test-runtime-utils\";\nimport { ConsensusRegisterCollectionFactory } from \"../consensusRegisterCollectionFactory.js\";\nimport { IConsensusRegisterCollection } from \"../interfaces.js\";\n\nfunction createConnectedCollection(id: string, runtimeFactory: MockContainerRuntimeFactory) {\n\tconst dataStoreRuntime = new MockFluidDataStoreRuntime();\n\truntimeFactory.createContainerRuntime(dataStoreRuntime);\n\tconst services = {\n\t\tdeltaConnection: dataStoreRuntime.createDeltaConnection(),\n\t\tobjectStorage: new MockStorage(),\n\t};\n\n\tconst crcFactory = new ConsensusRegisterCollectionFactory();\n\tconst collection = crcFactory.create(dataStoreRuntime, id);\n\tcollection.connect(services);\n\treturn collection;\n}\n\nfunction createLocalCollection(id: string) {\n\tconst factory = new ConsensusRegisterCollectionFactory();\n\treturn factory.create(new MockFluidDataStoreRuntime(), id);\n}\n\nfunction createCollectionForReconnection(\n\tid: string,\n\truntimeFactory: MockContainerRuntimeFactoryForReconnection,\n) {\n\tconst dataStoreRuntime = new MockFluidDataStoreRuntime();\n\tconst containerRuntime = runtimeFactory.createContainerRuntime(dataStoreRuntime);\n\tconst services = {\n\t\tdeltaConnection: dataStoreRuntime.createDeltaConnection(),\n\t\tobjectStorage: new MockStorage(),\n\t};\n\n\tconst crcFactory = new ConsensusRegisterCollectionFactory();\n\tconst collection = crcFactory.create(dataStoreRuntime, id);\n\tcollection.connect(services);\n\treturn { collection, containerRuntime };\n}\n\ndescribe(\"ConsensusRegisterCollection\", () => {\n\tdescribe(\"Single connected client\", () => {\n\t\tconst collectionId = \"consensus-register-collection\";\n\t\tlet crc: IConsensusRegisterCollection;\n\t\tlet containerRuntimeFactory: MockContainerRuntimeFactory;\n\n\t\tbeforeEach(() => {\n\t\t\tcontainerRuntimeFactory = new MockContainerRuntimeFactory();\n\t\t\tcrc = createConnectedCollection(collectionId, containerRuntimeFactory);\n\t\t});\n\n\t\tasync function writeAndProcessMsg(key: string, value: any) {\n\t\t\tconst waitP = crc.write(key, value);\n\t\t\tcontainerRuntimeFactory.processAllMessages();\n\t\t\treturn waitP;\n\t\t}\n\n\t\tdescribe(\"API\", () => {\n\t\t\tit(\"Can create a collection\", () => {\n\t\t\t\tassert.ok(crc);\n\t\t\t});\n\n\t\t\tit(\"Can add and remove data\", async () => {\n\t\t\t\tassert.strictEqual(crc.read(\"key1\"), undefined);\n\t\t\t\tconst writeResult = await writeAndProcessMsg(\"key1\", \"val1\");\n\t\t\t\tassert.strictEqual(crc.read(\"key1\"), \"val1\");\n\t\t\t\tassert.strictEqual(writeResult, true, \"No concurrency expected\");\n\t\t\t});\n\n\t\t\tit(\"Can add and remove a handle\", async () => {\n\t\t\t\tassert.strictEqual(crc.read(\"key1\"), undefined);\n\t\t\t\tconst handle = crc.handle;\n\t\t\t\tif (handle === undefined) {\n\t\t\t\t\tassert.fail(\"Need an actual handle to test this case\");\n\t\t\t\t}\n\t\t\t\tconst writeResult = await writeAndProcessMsg(\"key1\", handle);\n\t\t\t\tconst readValue = crc.read(\"key1\");\n\t\t\t\tassert.strictEqual(readValue.absolutePath, handle.absolutePath);\n\t\t\t\tassert.strictEqual(writeResult, true, \"No concurrency expected\");\n\t\t\t});\n\n\t\t\tit(\"Change events emit the right key/value\", async () => {\n\t\t\t\tcrc.on(\"atomicChanged\", (key: string, value: any, local: boolean) => {\n\t\t\t\t\tassert.strictEqual(key, \"key1\", \"atomicChanged event emitted the wrong key\");\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\"val1\",\n\t\t\t\t\t\t\"atomicChanged event emitted the wrong value\",\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tcrc.on(\"versionChanged\", (key: string, value: any, local: boolean) => {\n\t\t\t\t\tassert.strictEqual(key, \"key1\", \"versionChanged event emitted the wrong key\");\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\"val1\",\n\t\t\t\t\t\t\"versionChanged event emitted the wrong value\",\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tawait writeAndProcessMsg(\"key1\", \"val1\");\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"Summary\", () => {\n\t\t\tconst snapshotFileName = \"header\";\n\t\t\tconst expectedSerialization = JSON.stringify({\n\t\t\t\tkey1: {\n\t\t\t\t\tatomic: { sequenceNumber: 1, value: { type: \"Plain\", value: \"val1.1\" } },\n\t\t\t\t\tversions: [{ sequenceNumber: 1, value: { type: \"Plain\", value: \"val1.1\" } }],\n\t\t\t\t},\n\t\t\t});\n\t\t\tconst legacySharedObjectSerialization = JSON.stringify({\n\t\t\t\tkey1: {\n\t\t\t\t\tatomic: { sequenceNumber: 1, value: { type: \"Shared\", value: \"sharedObjId\" } },\n\t\t\t\t\tversions: [\n\t\t\t\t\t\t{ sequenceNumber: 1, value: { type: \"Shared\", value: \"sharedObjId\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t});\n\t\t\tconst buildTree = (serialized: string) => ({\n\t\t\t\tentries: [new BlobTreeEntry(snapshotFileName, serialized)],\n\t\t\t});\n\n\t\t\tit(\"summarize\", async () => {\n\t\t\t\tawait writeAndProcessMsg(\"key1\", \"val1.1\");\n\t\t\t\tconst summaryTree = crc.getAttachSummary().summary;\n\t\t\t\tassert(\n\t\t\t\t\tObject.keys(summaryTree.tree).length === 1,\n\t\t\t\t\t\"summarize should return a tree with single blob\",\n\t\t\t\t);\n\t\t\t\tconst serialized = (summaryTree.tree.header as ISummaryBlob)?.content as string;\n\t\t\t\tassert(serialized, \"summarize should return a tree with blob with contents\");\n\t\t\t\tassert.strictEqual(serialized, expectedSerialization);\n\t\t\t});\n\n\t\t\tit(\"load\", async () => {\n\t\t\t\tconst tree: ITree = buildTree(expectedSerialization);\n\t\t\t\tconst services = {\n\t\t\t\t\tdeltaConnection: new MockEmptyDeltaConnection(),\n\t\t\t\t\tobjectStorage: new MockStorage(tree),\n\t\t\t\t};\n\t\t\t\tconst crcFactory = new ConsensusRegisterCollectionFactory();\n\t\t\t\tconst loadedCrc = await crcFactory.load(\n\t\t\t\t\tnew MockFluidDataStoreRuntime(),\n\t\t\t\t\tcollectionId,\n\t\t\t\t\tservices,\n\t\t\t\t\tConsensusRegisterCollectionFactory.Attributes,\n\t\t\t\t);\n\t\t\t\tassert.strictEqual(loadedCrc.read(\"key1\"), \"val1.1\");\n\t\t\t});\n\n\t\t\tit(\"load with SharedObject not supported\", async () => {\n\t\t\t\tconst tree: ITree = buildTree(legacySharedObjectSerialization);\n\t\t\t\tconst services = {\n\t\t\t\t\tdeltaConnection: new MockEmptyDeltaConnection(),\n\t\t\t\t\tobjectStorage: new MockStorage(tree),\n\t\t\t\t};\n\t\t\t\tconst crcFactory = new ConsensusRegisterCollectionFactory();\n\t\t\t\tawait assert.rejects(\n\t\t\t\t\tcrcFactory.load(\n\t\t\t\t\t\tnew MockFluidDataStoreRuntime(),\n\t\t\t\t\t\tcollectionId,\n\t\t\t\t\t\tservices,\n\t\t\t\t\t\tConsensusRegisterCollectionFactory.Attributes,\n\t\t\t\t\t),\n\t\t\t\t\t\"SharedObjects contained in ConsensusRegisterCollection can no longer be deserialized\",\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"Multiple Clients\", () => {\n\t\tdescribe(\"Local state\", () => {\n\t\t\tlet containerRuntimeFactory: MockContainerRuntimeFactory;\n\t\t\tlet testCollection1: IConsensusRegisterCollection;\n\t\t\tlet testCollection2: IConsensusRegisterCollection;\n\n\t\t\tbeforeEach(() => {\n\t\t\t\tcontainerRuntimeFactory = new MockContainerRuntimeFactoryForReconnection();\n\t\t\t\ttestCollection1 = createLocalCollection(\"collection1\");\n\t\t\t\ttestCollection2 = createLocalCollection(\"collection2\");\n\t\t\t});\n\n\t\t\tit(\"should not send ops when the collection is not connected\", async () => {\n\t\t\t\t// Add a listener to the second collection. This is used to verify that the written value reaches\n\t\t\t\t// the remote client.\n\t\t\t\tlet receivedValue: string = \"\";\n\t\t\t\ttestCollection2.on(\"atomicChanged\", (key: string, value: string) => {\n\t\t\t\t\treceivedValue = value;\n\t\t\t\t});\n\n\t\t\t\t// Write to the first register collection.\n\t\t\t\tconst testValue = \"testValue\";\n\t\t\t\tconst writeP = testCollection1.write(\"key\", testValue);\n\n\t\t\t\t// Process the messages.\n\t\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t\t// Verify that the first collection successfully writes and is the winner.\n\t\t\t\tconst winner = await writeP;\n\t\t\t\tassert.equal(winner, true, \"Write was not successful\");\n\n\t\t\t\t// Verify that the remote client does not get this write because the DDS is not connected.\n\t\t\t\tassert.equal(\n\t\t\t\t\treceivedValue,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"The remote client should not have received the write\",\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\"Reconnection\", () => {\n\t\t\tconst testKey: string = \"testKey\";\n\t\t\tconst testValue: string = \"testValue\";\n\t\t\tlet receivedKey: string = \"\";\n\t\t\tlet receivedValue: string = \"\";\n\t\t\tlet receivedLocalStatus: boolean = true;\n\n\t\t\tlet containerRuntimeFactory: MockContainerRuntimeFactoryForReconnection;\n\t\t\tlet containerRuntime1: MockContainerRuntimeForReconnection;\n\t\t\tlet testCollection1: IConsensusRegisterCollection;\n\t\t\tlet testCollection2: IConsensusRegisterCollection;\n\n\t\t\tbeforeEach(() => {\n\t\t\t\tcontainerRuntimeFactory = new MockContainerRuntimeFactoryForReconnection();\n\t\t\t\tconst response1 = createCollectionForReconnection(\n\t\t\t\t\t\"collection1\",\n\t\t\t\t\tcontainerRuntimeFactory,\n\t\t\t\t);\n\t\t\t\ttestCollection1 = response1.collection;\n\t\t\t\tcontainerRuntime1 = response1.containerRuntime;\n\n\t\t\t\tconst response2 = createCollectionForReconnection(\n\t\t\t\t\t\"collection2\",\n\t\t\t\t\tcontainerRuntimeFactory,\n\t\t\t\t);\n\t\t\t\ttestCollection2 = response2.collection;\n\n\t\t\t\t// Add a listener to the second collection. This is used to verify that the written value reaches\n\t\t\t\t// the remote client.\n\t\t\t\ttestCollection2.on(\n\t\t\t\t\t\"atomicChanged\",\n\t\t\t\t\t(key: string, value: string, local: boolean) => {\n\t\t\t\t\t\treceivedKey = key;\n\t\t\t\t\t\treceivedValue = value;\n\t\t\t\t\t\treceivedLocalStatus = local;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tit(\"can resend unacked ops on reconnection\", async () => {\n\t\t\t\t// Write to the first register collection.\n\t\t\t\tconst writeP = testCollection1.write(testKey, testValue);\n\n\t\t\t\t// Disconnect and reconnect the first collection.\n\t\t\t\tcontainerRuntime1.connected = false;\n\t\t\t\tcontainerRuntime1.connected = true;\n\n\t\t\t\t// Process the messages.\n\t\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t\t// Verify that the first collection successfully writes and is the winner.\n\t\t\t\tconst winner = await writeP;\n\t\t\t\tassert.equal(winner, true, \"Write was not successful\");\n\n\t\t\t\t// Verify that the remote register collection received the write.\n\t\t\t\tassert.equal(receivedKey, testKey, \"The remote client did not receive the key\");\n\t\t\t\tassert.equal(\n\t\t\t\t\treceivedValue,\n\t\t\t\t\ttestValue,\n\t\t\t\t\t\"The remote client did not receive the value\",\n\t\t\t\t);\n\t\t\t\tassert.equal(\n\t\t\t\t\treceivedLocalStatus,\n\t\t\t\t\tfalse,\n\t\t\t\t\t\"The remote client's value should not be local\",\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tit(\"can store ops in disconnected state and resend them on reconnection\", async () => {\n\t\t\t\t// Disconnect the first collection.\n\t\t\t\tcontainerRuntime1.connected = false;\n\n\t\t\t\t// Write to the first register collection.\n\t\t\t\tconst writeP = testCollection1.write(testKey, testValue);\n\n\t\t\t\t// Reconnect the first collection.\n\t\t\t\tcontainerRuntime1.connected = true;\n\n\t\t\t\t// Process the messages.\n\t\t\t\tcontainerRuntimeFactory.processAllMessages();\n\n\t\t\t\t// Verify that the first collection successfully writes and is the winner.\n\t\t\t\tconst winner = await writeP;\n\t\t\t\tassert.equal(winner, true, \"Write was not successful\");\n\n\t\t\t\t// Verify that the remote register collection received the write.\n\t\t\t\tassert.equal(receivedKey, testKey, \"The remote client did not receive the key\");\n\t\t\t\tassert.equal(\n\t\t\t\t\treceivedValue,\n\t\t\t\t\ttestValue,\n\t\t\t\t\t\"The remote client did not receive the value\",\n\t\t\t\t);\n\t\t\t\tassert.equal(\n\t\t\t\t\treceivedLocalStatus,\n\t\t\t\t\tfalse,\n\t\t\t\t\t\"The remote client's value should not be local\",\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tafterEach(() => {\n\t\t\t\treceivedKey = \"\";\n\t\t\t\treceivedValue = \"\";\n\t\t\t\treceivedLocalStatus = true;\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe(\"Garbage Collection\", () => {\n\t\tclass GCRegisteredCollectionProvider implements IGCTestProvider {\n\t\t\tprivate subCollectionCount = 0;\n\t\t\tprivate _expectedRoutes: string[] = [];\n\t\t\tprivate readonly collection1: IConsensusRegisterCollection;\n\t\t\tprivate readonly collection2: IConsensusRegisterCollection;\n\t\t\tprivate readonly containerRuntimeFactory: MockContainerRuntimeFactory;\n\n\t\t\tconstructor() {\n\t\t\t\tthis.containerRuntimeFactory = new MockContainerRuntimeFactory();\n\t\t\t\tthis.collection1 = createConnectedCollection(\n\t\t\t\t\t\"collection1\",\n\t\t\t\t\tthis.containerRuntimeFactory,\n\t\t\t\t);\n\t\t\t\tthis.collection2 = createConnectedCollection(\n\t\t\t\t\t\"collection2\",\n\t\t\t\t\tthis.containerRuntimeFactory,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprivate async writeAndProcessMsg(key: string, value: any) {\n\t\t\t\tconst waitP = this.collection1.write(key, value);\n\t\t\t\tthis.containerRuntimeFactory.processAllMessages();\n\t\t\t\treturn waitP;\n\t\t\t}\n\n\t\t\tpublic get sharedObject() {\n\t\t\t\t// Return the remote collection because we want to verify its summary data.\n\t\t\t\treturn this.collection2;\n\t\t\t}\n\n\t\t\tpublic get expectedOutboundRoutes() {\n\t\t\t\treturn this._expectedRoutes;\n\t\t\t}\n\n\t\t\tpublic async addOutboundRoutes() {\n\t\t\t\tconst subCollectionId = `subCollection-${++this.subCollectionCount}`;\n\t\t\t\tconst subTestCollection = createLocalCollection(subCollectionId);\n\t\t\t\tawait this.writeAndProcessMsg(subCollectionId, subTestCollection.handle);\n\t\t\t\tthis._expectedRoutes.push(subTestCollection.handle.absolutePath);\n\t\t\t}\n\n\t\t\tpublic async deleteOutboundRoutes() {\n\t\t\t\tconst subCollectionId = `subCollection-${this.subCollectionCount}`;\n\t\t\t\tconst deletedHandle = this.collection1.read(subCollectionId) as IFluidHandle;\n\t\t\t\tassert(deletedHandle, \"Route must be added before deleting\");\n\n\t\t\t\t// Delete the last handle that was added.\n\t\t\t\tawait this.writeAndProcessMsg(subCollectionId, \"nonHandleValue\");\n\t\t\t\t// Remove deleted handle's route from expected routes.\n\t\t\t\tthis._expectedRoutes = this._expectedRoutes.filter(\n\t\t\t\t\t(route) => route !== deletedHandle.absolutePath,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic async addNestedHandles() {\n\t\t\t\tconst subCollectionId1 = `subCollection-${++this.subCollectionCount}`;\n\t\t\t\tconst subCollectionId2 = `subCollection-${++this.subCollectionCount}`;\n\t\t\t\tconst subTestCollection1 = createLocalCollection(subCollectionId1);\n\t\t\t\tconst subTestCollection2 = createLocalCollection(subCollectionId2);\n\t\t\t\tconst containingObject = {\n\t\t\t\t\tcollection1Handle: subTestCollection1.handle,\n\t\t\t\t\tnestedObj: {\n\t\t\t\t\t\tcollection2Handle: subTestCollection2.handle,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tawait this.writeAndProcessMsg(subCollectionId2, containingObject);\n\t\t\t\tthis._expectedRoutes.push(\n\t\t\t\t\tsubTestCollection1.handle.absolutePath,\n\t\t\t\t\tsubTestCollection2.handle.absolutePath,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\trunGCTests(GCRegisteredCollectionProvider);\n\t});\n});\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
use_current_ClassDeclaration_ConsensusRegisterCollection(get_old_ClassDeclaration_ConsensusRegisterCollection());
|
|
2
|
-
use_old_ClassDeclaration_ConsensusRegisterCollection(get_current_ClassDeclaration_ConsensusRegisterCollection());
|
|
3
|
-
use_current_ClassDeclaration_ConsensusRegisterCollectionFactory(get_old_ClassDeclaration_ConsensusRegisterCollectionFactory());
|
|
4
|
-
use_old_ClassDeclaration_ConsensusRegisterCollectionFactory(get_current_ClassDeclaration_ConsensusRegisterCollectionFactory());
|
|
5
|
-
use_current_InterfaceDeclaration_IConsensusRegisterCollection(get_old_InterfaceDeclaration_IConsensusRegisterCollection());
|
|
6
|
-
use_old_InterfaceDeclaration_IConsensusRegisterCollection(get_current_InterfaceDeclaration_IConsensusRegisterCollection());
|
|
7
|
-
use_current_InterfaceDeclaration_IConsensusRegisterCollectionEvents(get_old_InterfaceDeclaration_IConsensusRegisterCollectionEvents());
|
|
8
|
-
use_old_InterfaceDeclaration_IConsensusRegisterCollectionEvents(get_current_InterfaceDeclaration_IConsensusRegisterCollectionEvents());
|
|
9
|
-
use_current_InterfaceDeclaration_IConsensusRegisterCollectionFactory(get_old_InterfaceDeclaration_IConsensusRegisterCollectionFactory());
|
|
10
|
-
use_old_InterfaceDeclaration_IConsensusRegisterCollectionFactory(get_current_InterfaceDeclaration_IConsensusRegisterCollectionFactory());
|
|
11
|
-
use_current_EnumDeclaration_ReadPolicy(get_old_EnumDeclaration_ReadPolicy());
|
|
12
|
-
use_old_EnumDeclaration_ReadPolicy(get_current_EnumDeclaration_ReadPolicy());
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=validateRegisterCollectionPrevious.generated.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateRegisterCollectionPrevious.generated.js","sourceRoot":"","sources":["../../../src/test/types/validateRegisterCollectionPrevious.generated.ts"],"names":[],"mappings":"AAgCA,wDAAwD,CACpD,oDAAoD,EAAE,CAAC,CAAC;AAW5D,oDAAoD,CAChD,wDAAwD,EAAE,CAAC,CAAC;AAWhE,+DAA+D,CAC3D,2DAA2D,EAAE,CAAC,CAAC;AAWnE,2DAA2D,CACvD,+DAA+D,EAAE,CAAC,CAAC;AAWvE,6DAA6D,CACzD,yDAAyD,EAAE,CAAC,CAAC;AAWjE,yDAAyD,CACrD,6DAA6D,EAAE,CAAC,CAAC;AAWrE,mEAAmE,CAC/D,+DAA+D,EAAE,CAAC,CAAC;AAWvE,+DAA+D,CAC3D,mEAAmE,EAAE,CAAC,CAAC;AAW3E,oEAAoE,CAChE,gEAAgE,EAAE,CAAC,CAAC;AAWxE,gEAAgE,CAC5D,oEAAoE,EAAE,CAAC,CAAC;AAW5E,sCAAsC,CAClC,kCAAkC,EAAE,CAAC,CAAC;AAW1C,kCAAkC,CAC9B,sCAAsC,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/*\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * Generated by fluid-type-test-generator in @fluidframework/build-tools.\n */\nimport type * as old from \"@fluidframework/register-collection-previous\";\nimport type * as current from \"../../index.js\";\n\n\n// See 'build-tools/src/type-test-generator/compatibility.ts' for more information.\ntype TypeOnly<T> = T extends number\n\t? number\n\t: T extends string\n\t? string\n\t: T extends boolean | bigint | symbol\n\t? T\n\t: {\n\t\t\t[P in keyof T]: TypeOnly<T[P]>;\n\t };\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_ConsensusRegisterCollection\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_ConsensusRegisterCollection():\n TypeOnly<old.ConsensusRegisterCollection<any>>;\ndeclare function use_current_ClassDeclaration_ConsensusRegisterCollection(\n use: TypeOnly<current.ConsensusRegisterCollection<any>>): void;\nuse_current_ClassDeclaration_ConsensusRegisterCollection(\n get_old_ClassDeclaration_ConsensusRegisterCollection());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_ConsensusRegisterCollection\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_ConsensusRegisterCollection():\n TypeOnly<current.ConsensusRegisterCollection<any>>;\ndeclare function use_old_ClassDeclaration_ConsensusRegisterCollection(\n use: TypeOnly<old.ConsensusRegisterCollection<any>>): void;\nuse_old_ClassDeclaration_ConsensusRegisterCollection(\n get_current_ClassDeclaration_ConsensusRegisterCollection());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_ConsensusRegisterCollectionFactory\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_ConsensusRegisterCollectionFactory():\n TypeOnly<old.ConsensusRegisterCollectionFactory>;\ndeclare function use_current_ClassDeclaration_ConsensusRegisterCollectionFactory(\n use: TypeOnly<current.ConsensusRegisterCollectionFactory>): void;\nuse_current_ClassDeclaration_ConsensusRegisterCollectionFactory(\n get_old_ClassDeclaration_ConsensusRegisterCollectionFactory());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_ConsensusRegisterCollectionFactory\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_ConsensusRegisterCollectionFactory():\n TypeOnly<current.ConsensusRegisterCollectionFactory>;\ndeclare function use_old_ClassDeclaration_ConsensusRegisterCollectionFactory(\n use: TypeOnly<old.ConsensusRegisterCollectionFactory>): void;\nuse_old_ClassDeclaration_ConsensusRegisterCollectionFactory(\n get_current_ClassDeclaration_ConsensusRegisterCollectionFactory());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IConsensusRegisterCollection\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IConsensusRegisterCollection():\n TypeOnly<old.IConsensusRegisterCollection>;\ndeclare function use_current_InterfaceDeclaration_IConsensusRegisterCollection(\n use: TypeOnly<current.IConsensusRegisterCollection>): void;\nuse_current_InterfaceDeclaration_IConsensusRegisterCollection(\n get_old_InterfaceDeclaration_IConsensusRegisterCollection());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IConsensusRegisterCollection\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IConsensusRegisterCollection():\n TypeOnly<current.IConsensusRegisterCollection>;\ndeclare function use_old_InterfaceDeclaration_IConsensusRegisterCollection(\n use: TypeOnly<old.IConsensusRegisterCollection>): void;\nuse_old_InterfaceDeclaration_IConsensusRegisterCollection(\n get_current_InterfaceDeclaration_IConsensusRegisterCollection());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IConsensusRegisterCollectionEvents\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IConsensusRegisterCollectionEvents():\n TypeOnly<old.IConsensusRegisterCollectionEvents>;\ndeclare function use_current_InterfaceDeclaration_IConsensusRegisterCollectionEvents(\n use: TypeOnly<current.IConsensusRegisterCollectionEvents>): void;\nuse_current_InterfaceDeclaration_IConsensusRegisterCollectionEvents(\n get_old_InterfaceDeclaration_IConsensusRegisterCollectionEvents());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IConsensusRegisterCollectionEvents\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IConsensusRegisterCollectionEvents():\n TypeOnly<current.IConsensusRegisterCollectionEvents>;\ndeclare function use_old_InterfaceDeclaration_IConsensusRegisterCollectionEvents(\n use: TypeOnly<old.IConsensusRegisterCollectionEvents>): void;\nuse_old_InterfaceDeclaration_IConsensusRegisterCollectionEvents(\n get_current_InterfaceDeclaration_IConsensusRegisterCollectionEvents());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IConsensusRegisterCollectionFactory\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IConsensusRegisterCollectionFactory():\n TypeOnly<old.IConsensusRegisterCollectionFactory>;\ndeclare function use_current_InterfaceDeclaration_IConsensusRegisterCollectionFactory(\n use: TypeOnly<current.IConsensusRegisterCollectionFactory>): void;\nuse_current_InterfaceDeclaration_IConsensusRegisterCollectionFactory(\n get_old_InterfaceDeclaration_IConsensusRegisterCollectionFactory());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IConsensusRegisterCollectionFactory\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IConsensusRegisterCollectionFactory():\n TypeOnly<current.IConsensusRegisterCollectionFactory>;\ndeclare function use_old_InterfaceDeclaration_IConsensusRegisterCollectionFactory(\n use: TypeOnly<old.IConsensusRegisterCollectionFactory>): void;\nuse_old_InterfaceDeclaration_IConsensusRegisterCollectionFactory(\n get_current_InterfaceDeclaration_IConsensusRegisterCollectionFactory());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"EnumDeclaration_ReadPolicy\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_EnumDeclaration_ReadPolicy():\n TypeOnly<old.ReadPolicy>;\ndeclare function use_current_EnumDeclaration_ReadPolicy(\n use: TypeOnly<current.ReadPolicy>): void;\nuse_current_EnumDeclaration_ReadPolicy(\n get_old_EnumDeclaration_ReadPolicy());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"EnumDeclaration_ReadPolicy\": {\"backCompat\": false}\n*/\ndeclare function get_current_EnumDeclaration_ReadPolicy():\n TypeOnly<current.ReadPolicy>;\ndeclare function use_old_EnumDeclaration_ReadPolicy(\n use: TypeOnly<old.ReadPolicy>): void;\nuse_old_EnumDeclaration_ReadPolicy(\n get_current_EnumDeclaration_ReadPolicy());\n"]}
|