@fluid-experimental/tree 0.59.4001 → 1.1.0-75972
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/EditLog.d.ts.map +1 -1
- package/dist/EditLog.js +4 -7
- package/dist/EditLog.js.map +1 -1
- package/dist/LogViewer.d.ts.map +1 -1
- package/dist/LogViewer.js +1 -7
- package/dist/LogViewer.js.map +1 -1
- package/dist/SharedTree.d.ts +89 -30
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +97 -62
- package/dist/SharedTree.js.map +1 -1
- package/dist/SharedTreeEncoder.d.ts +1 -1
- package/dist/SharedTreeEncoder.d.ts.map +1 -1
- package/dist/SharedTreeEncoder.js +6 -12
- package/dist/SharedTreeEncoder.js.map +1 -1
- package/dist/TransactionInternal.d.ts.map +1 -1
- package/dist/TransactionInternal.js +4 -7
- package/dist/TransactionInternal.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts +3 -1
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +45 -17
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/lib/EditLog.d.ts.map +1 -1
- package/lib/EditLog.js +4 -7
- package/lib/EditLog.js.map +1 -1
- package/lib/LogViewer.d.ts.map +1 -1
- package/lib/LogViewer.js +1 -7
- package/lib/LogViewer.js.map +1 -1
- package/lib/SharedTree.d.ts +89 -30
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +98 -63
- package/lib/SharedTree.js.map +1 -1
- package/lib/SharedTreeEncoder.d.ts +1 -1
- package/lib/SharedTreeEncoder.d.ts.map +1 -1
- package/lib/SharedTreeEncoder.js +6 -12
- package/lib/SharedTreeEncoder.js.map +1 -1
- package/lib/TransactionInternal.d.ts.map +1 -1
- package/lib/TransactionInternal.js +4 -7
- package/lib/TransactionInternal.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts +3 -1
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +45 -17
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +1 -1
- package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -1
- package/lib/test/SessionIdNormalizer.tests.js +4 -6
- package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
- package/lib/test/Summary.tests.js +3 -6
- package/lib/test/Summary.tests.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +3 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeTests.js +59 -60
- package/lib/test/utilities/SharedTreeTests.js.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
- package/lib/test/utilities/SharedTreeVersioningTests.js +19 -19
- package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
- package/lib/test/utilities/TestNode.d.ts.map +1 -1
- package/lib/test/utilities/TestNode.js +2 -12
- package/lib/test/utilities/TestNode.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +11 -11
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +19 -32
- package/src/EditLog.ts +21 -23
- package/src/LogViewer.ts +1 -6
- package/src/SharedTree.ts +200 -50
- package/src/SharedTreeEncoder.ts +7 -18
- package/src/TransactionInternal.ts +11 -13
- package/src/id-compressor/IdCompressor.ts +46 -15
- package/src/index.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shared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Q,CAAC,4BAA4B,EAAE,GAAG,EAAE;YAC3C,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { existsSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { expect } from 'chai';\nimport {\n\tAsyncGenerator,\n\tchainAsync as chain,\n\tmakeRandom,\n\ttakeAsync as take,\n\tperformFuzzActionsAsync as performFuzzActionsBase,\n} from '@fluid-internal/stochastic-test-utils';\nimport { setUpLocalServerTestSharedTree, testDocumentsPathBase } from '../utilities/TestUtilities';\nimport { WriteFormat } from '../../persisted-types';\nimport { fail } from '../../Common';\nimport { areRevisionViewsSemanticallyEqual } from '../../EditUtilities';\nimport { FuzzTestState, EditGenerationConfig, Operation } from './Types';\nimport { makeOpGenerator } from './Generators';\n\nconst directory = join(testDocumentsPathBase, 'fuzz-tests');\n\n// TODO: Kludge: Use this to change the seed such that the tests avoid hitting bugs in the Fluid Framework.\n// Should be removed once fuzz tests pass reliably with any seed.\nconst adjustSeed = 0;\n\n/**\n * Performs random actions on a set of clients.\n * @param generator - finite generator for a sequence of Operations to test. The test will run until this generator is\n * exhausted.\n * @param seed - the seed for the random generation of the fuzz actions\n * @param synchronizeAtEnd - if provided, all client will have all operations delivered from the server at the end of\n * the test\n * @param saveInfo - optionally provide an operation number at which a history of all operations will be saved to disk\n * at a given filepath. This can be useful for debugging why a fuzz test may have failed.\n */\nexport async function performFuzzActions(\n\tgenerator: AsyncGenerator<Operation, FuzzTestState>,\n\tseed: number,\n\tsynchronizeAtEnd: boolean = true,\n\tsaveInfo?: { saveAt?: number; saveOnFailure: boolean; filepath: string }\n): Promise<Required<FuzzTestState>> {\n\tconst random = makeRandom(seed);\n\n\t// Note: the direct fields of `state` aren't mutated, but it is mutated transitively.\n\tconst initialState: FuzzTestState = { random, passiveCollaborators: [], activeCollaborators: [] };\n\tconst finalState = await performFuzzActionsBase(\n\t\tgenerator,\n\t\t{\n\t\t\tedit: async (state, operation) => {\n\t\t\t\tconst { index, contents } = operation;\n\t\t\t\tconst { tree } = state.activeCollaborators[index];\n\t\t\t\tswitch (contents.fuzzType) {\n\t\t\t\t\tcase 'insert':\n\t\t\t\t\t\ttree.applyEdit(contents.build, contents.insert);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'delete':\n\t\t\t\t\t\ttree.applyEdit(contents);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'move':\n\t\t\t\t\t\ttree.applyEdit(contents.detach, contents.insert);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'setPayload':\n\t\t\t\t\t\ttree.applyEdit(contents);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tfail('Invalid edit.');\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tjoin: async (state, operation) => {\n\t\t\t\tconst { isObserver, summarizeHistory, writeFormat } = operation;\n\t\t\t\tconst { container, tree, testObjectProvider } = await setUpLocalServerTestSharedTree({\n\t\t\t\t\twriteFormat,\n\t\t\t\t\tsummarizeHistory,\n\t\t\t\t\ttestObjectProvider: state.testObjectProvider,\n\t\t\t\t});\n\t\t\t\t(isObserver ? state.passiveCollaborators : state.activeCollaborators).push({ container, tree });\n\t\t\t\treturn { ...state, testObjectProvider };\n\t\t\t},\n\t\t\tleave: async (state, operation) => {\n\t\t\t\tconst { index, isObserver } = operation;\n\t\t\t\tconst treeList = isObserver ? state.passiveCollaborators : state.activeCollaborators;\n\t\t\t\ttreeList[index].container.close();\n\t\t\t\ttreeList.splice(index, 1);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tsynchronize: async (state) => {\n\t\t\t\tconst { testObjectProvider } = state;\n\t\t\t\tif (testObjectProvider === undefined) {\n\t\t\t\t\tfail('Attempted to synchronize with undefined testObjectProvider');\n\t\t\t\t}\n\t\t\t\tawait testObjectProvider.ensureSynchronized();\n\t\t\t\tconst trees = [...state.activeCollaborators, ...state.passiveCollaborators];\n\t\t\t\tif (trees.length > 1) {\n\t\t\t\t\tconst first = trees[0].tree;\n\t\t\t\t\tfor (let i = 1; i < trees.length; i++) {\n\t\t\t\t\t\tconst tree = trees[i].tree;\n\t\t\t\t\t\tconst editLogA = first.edits;\n\t\t\t\t\t\tconst editLogB = tree.edits;\n\t\t\t\t\t\tconst minEdits = Math.min(editLogA.length, editLogB.length);\n\t\t\t\t\t\tfor (let j = 0; j < minEdits - 1; j++) {\n\t\t\t\t\t\t\tconst editA = await editLogA.getEditAtIndex(editLogA.length - j - 1);\n\t\t\t\t\t\t\tconst editB = await editLogB.getEditAtIndex(editLogB.length - j - 1);\n\t\t\t\t\t\t\texpect(editA.id).to.equal(editB.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\texpect(areRevisionViewsSemanticallyEqual(tree.currentView, tree, first.currentView, first)).to\n\t\t\t\t\t\t\t.be.true;\n\n\t\t\t\t\t\t// TODO:#461: Compare attribution info of all nodes in currentView to all nodes in `first`\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn state;\n\t\t\t},\n\t\t},\n\t\tinitialState,\n\t\tsaveInfo\n\t);\n\n\tif (synchronizeAtEnd) {\n\t\tif (finalState.testObjectProvider !== undefined) {\n\t\t\tawait finalState.testObjectProvider.ensureSynchronized();\n\t\t\tconst events = finalState.testObjectProvider.logger.reportAndClearTrackedEvents();\n\t\t\texpect(events.expectedNotFound.length).to.equal(0);\n\t\t\t// Tolerate failed edit chunk uploads, because they are fire-and-forget and can fail (e.g. the uploading client leaves before upload completes).\n\t\t\texpect(\n\t\t\t\tevents.unexpectedErrors.every(\n\t\t\t\t\t(e) => e.eventName === 'fluid:telemetry:FluidDataStoreRuntime:SharedTree:EditChunkUploadFailure'\n\t\t\t\t)\n\t\t\t).to.be.true;\n\t\t}\n\t\tconst trees = [\n\t\t\t...finalState.activeCollaborators.map(({ tree }) => tree),\n\t\t\t...finalState.passiveCollaborators.map(({ tree }) => tree),\n\t\t];\n\t\tfor (let i = 0; i < trees.length - 1; i++) {\n\t\t\texpect(trees[i].equals(trees[i + 1]));\n\t\t}\n\t}\n\n\treturn finalState as Required<FuzzTestState>;\n}\n\nexport function runSharedTreeFuzzTests(title: string): void {\n\t// Some useful tips for debugging fuzz tests:\n\t// - A JSON dump of the operation sequence can be written to disk by passing `true` for `saveOnFailure`.\n\t// - Different shared-tree instances can be distinguished (e.g. in logs) by using `tree.getRuntime().clientId`\n\tdescribe(title, () => {\n\t\tfunction runTest(\n\t\t\tgeneratorFactory: () => AsyncGenerator<Operation, FuzzTestState>,\n\t\t\tseed: number,\n\t\t\tsaveOnFailure?: boolean\n\t\t): void {\n\t\t\tit(`with seed ${seed}`, async () => {\n\t\t\t\tconst saveInfo =\n\t\t\t\t\tsaveOnFailure !== undefined\n\t\t\t\t\t\t? { filepath: join(directory, `test-history-${seed}.json`), saveOnFailure }\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (saveInfo !== undefined && !existsSync(directory)) {\n\t\t\t\t\tmkdirSync(directory);\n\t\t\t\t}\n\t\t\t\tawait performFuzzActions(generatorFactory(), seed + adjustSeed, true, saveInfo);\n\t\t\t}).timeout(10000);\n\t\t}\n\n\t\tfunction runMixedVersionTests(summarizeHistory: boolean, testsPerSuite: number, testLength: number): void {\n\t\t\tdescribe('using 0.0.2 and 0.1.1 trees', () => {\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\ttake(testLength, makeOpGenerator({ joinConfig: { summarizeHistory: [summarizeHistory] } })),\n\t\t\t\t\t\tseed\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdescribe('using only version 0.0.2', () => {\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\t\ttestLength,\n\t\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_0_2],\n\t\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tseed\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdescribe('using only version 0.1.1', () => {\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\t\ttestLength,\n\t\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_1_1],\n\t\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tseed\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdescribe('upgrading halfway through', () => {\n\t\t\t\tconst maximumActiveCollaborators = 10;\n\t\t\t\tconst maximumPassiveCollaborators = 5;\n\t\t\t\tconst editConfig: EditGenerationConfig = { maxTreeSize: 1000 };\n\t\t\t\tconst generatorFactory = () =>\n\t\t\t\t\tchain(\n\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\ttestLength / 2 - 1,\n\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\teditConfig,\n\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\tmaximumActiveCollaborators,\n\t\t\t\t\t\t\t\t\tmaximumPassiveCollaborators,\n\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_0_2],\n\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\tmaximumActiveCollaborators: maximumActiveCollaborators + 1,\n\t\t\t\t\t\t\t\t\tmaximumPassiveCollaborators,\n\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_1_1],\n\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\teditWeight: 0,\n\t\t\t\t\t\t\t\tjoinWeight: 1,\n\t\t\t\t\t\t\t\tleaveWeight: 0,\n\t\t\t\t\t\t\t\tsynchronizeWeight: 0,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\ttestLength / 2,\n\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\teditConfig,\n\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\tmaximumActiveCollaborators,\n\t\t\t\t\t\t\t\t\tmaximumPassiveCollaborators,\n\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(generatorFactory, seed);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tconst testCount = 1;\n\t\tconst testLength = 200;\n\t\tdescribe('with no-history summarization', () => {\n\t\t\trunMixedVersionTests(false, testCount, testLength);\n\t\t});\n\n\t\tdescribe('with history summarization', () => {\n\t\t\trunMixedVersionTests(true, testCount, testLength);\n\t\t});\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SharedTreeFuzzTests.js","sourceRoot":"","sources":["../../../src/test/fuzz/SharedTreeFuzzTests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAEN,UAAU,IAAI,KAAK,EACnB,UAAU,EACV,SAAS,IAAI,IAAI,EACjB,uBAAuB,IAAI,sBAAsB,GACjD,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,SAAS,GAAG,IAAI,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;AAE5D,2GAA2G;AAC3G,iEAAiE;AACjE,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,SAAmD,EACnD,IAAY,EACZ,mBAA4B,IAAI,EAChC,QAAwE;IAExE,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAEhC,qFAAqF;IACrF,MAAM,YAAY,GAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC;IAClG,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;iBACD,CAAC,CACF,CACD,CAAC;gBACH,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,aAAa,EAAE,IAAI,EAAE,EAAE;oBAChD,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;iBAChC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,CAAC,CAAC;QACpB,MAAM,UAAU,GAAG,GAAG,CAAC;QACvB,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;YAC9C,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;YAC3C,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { existsSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { expect } from 'chai';\nimport {\n\tAsyncGenerator,\n\tchainAsync as chain,\n\tmakeRandom,\n\ttakeAsync as take,\n\tperformFuzzActionsAsync as performFuzzActionsBase,\n} from '@fluid-internal/stochastic-test-utils';\nimport { setUpLocalServerTestSharedTree, testDocumentsPathBase } from '../utilities/TestUtilities';\nimport { WriteFormat } from '../../persisted-types';\nimport { fail } from '../../Common';\nimport { areRevisionViewsSemanticallyEqual } from '../../EditUtilities';\nimport { FuzzTestState, EditGenerationConfig, Operation } from './Types';\nimport { makeOpGenerator } from './Generators';\n\nconst directory = join(testDocumentsPathBase, 'fuzz-tests');\n\n// TODO: Kludge: Use this to change the seed such that the tests avoid hitting bugs in the Fluid Framework.\n// Should be removed once fuzz tests pass reliably with any seed.\nconst adjustSeed = 0;\n\n/**\n * Performs random actions on a set of clients.\n * @param generator - finite generator for a sequence of Operations to test. The test will run until this generator is\n * exhausted.\n * @param seed - the seed for the random generation of the fuzz actions\n * @param synchronizeAtEnd - if provided, all client will have all operations delivered from the server at the end of\n * the test\n * @param saveInfo - optionally provide an operation number at which a history of all operations will be saved to disk\n * at a given filepath. This can be useful for debugging why a fuzz test may have failed.\n */\nexport async function performFuzzActions(\n\tgenerator: AsyncGenerator<Operation, FuzzTestState>,\n\tseed: number,\n\tsynchronizeAtEnd: boolean = true,\n\tsaveInfo?: { saveAt?: number; saveOnFailure: boolean; filepath: string }\n): Promise<Required<FuzzTestState>> {\n\tconst random = makeRandom(seed);\n\n\t// Note: the direct fields of `state` aren't mutated, but it is mutated transitively.\n\tconst initialState: FuzzTestState = { random, passiveCollaborators: [], activeCollaborators: [] };\n\tconst finalState = await performFuzzActionsBase(\n\t\tgenerator,\n\t\t{\n\t\t\tedit: async (state, operation) => {\n\t\t\t\tconst { index, contents } = operation;\n\t\t\t\tconst { tree } = state.activeCollaborators[index];\n\t\t\t\tswitch (contents.fuzzType) {\n\t\t\t\t\tcase 'insert':\n\t\t\t\t\t\ttree.applyEdit(contents.build, contents.insert);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'delete':\n\t\t\t\t\t\ttree.applyEdit(contents);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'move':\n\t\t\t\t\t\ttree.applyEdit(contents.detach, contents.insert);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'setPayload':\n\t\t\t\t\t\ttree.applyEdit(contents);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tfail('Invalid edit.');\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tjoin: async (state, operation) => {\n\t\t\t\tconst { isObserver, summarizeHistory, writeFormat } = operation;\n\t\t\t\tconst { container, tree, testObjectProvider } = await setUpLocalServerTestSharedTree({\n\t\t\t\t\twriteFormat,\n\t\t\t\t\tsummarizeHistory,\n\t\t\t\t\ttestObjectProvider: state.testObjectProvider,\n\t\t\t\t});\n\t\t\t\t(isObserver ? state.passiveCollaborators : state.activeCollaborators).push({ container, tree });\n\t\t\t\treturn { ...state, testObjectProvider };\n\t\t\t},\n\t\t\tleave: async (state, operation) => {\n\t\t\t\tconst { index, isObserver } = operation;\n\t\t\t\tconst treeList = isObserver ? state.passiveCollaborators : state.activeCollaborators;\n\t\t\t\ttreeList[index].container.close();\n\t\t\t\ttreeList.splice(index, 1);\n\t\t\t\treturn state;\n\t\t\t},\n\t\t\tsynchronize: async (state) => {\n\t\t\t\tconst { testObjectProvider } = state;\n\t\t\t\tif (testObjectProvider === undefined) {\n\t\t\t\t\tfail('Attempted to synchronize with undefined testObjectProvider');\n\t\t\t\t}\n\t\t\t\tawait testObjectProvider.ensureSynchronized();\n\t\t\t\tconst trees = [...state.activeCollaborators, ...state.passiveCollaborators];\n\t\t\t\tif (trees.length > 1) {\n\t\t\t\t\tconst first = trees[0].tree;\n\t\t\t\t\tfor (let i = 1; i < trees.length; i++) {\n\t\t\t\t\t\tconst tree = trees[i].tree;\n\t\t\t\t\t\tconst editLogA = first.edits;\n\t\t\t\t\t\tconst editLogB = tree.edits;\n\t\t\t\t\t\tconst minEdits = Math.min(editLogA.length, editLogB.length);\n\t\t\t\t\t\tfor (let j = 0; j < minEdits - 1; j++) {\n\t\t\t\t\t\t\tconst editA = await editLogA.getEditAtIndex(editLogA.length - j - 1);\n\t\t\t\t\t\t\tconst editB = await editLogB.getEditAtIndex(editLogB.length - j - 1);\n\t\t\t\t\t\t\texpect(editA.id).to.equal(editB.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\texpect(areRevisionViewsSemanticallyEqual(tree.currentView, tree, first.currentView, first)).to\n\t\t\t\t\t\t\t.be.true;\n\n\t\t\t\t\t\tfor (const node of tree.currentView) {\n\t\t\t\t\t\t\texpect(tree.attributeNodeId(node.identifier)).to.equal(\n\t\t\t\t\t\t\t\tfirst.attributeNodeId(\n\t\t\t\t\t\t\t\t\tfirst.convertToNodeId(tree.convertToStableNodeId(node.identifier))\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn state;\n\t\t\t},\n\t\t},\n\t\tinitialState,\n\t\tsaveInfo\n\t);\n\n\tif (synchronizeAtEnd) {\n\t\tif (finalState.testObjectProvider !== undefined) {\n\t\t\tawait finalState.testObjectProvider.ensureSynchronized();\n\t\t\tconst events = finalState.testObjectProvider.logger.reportAndClearTrackedEvents();\n\t\t\texpect(events.expectedNotFound.length).to.equal(0);\n\t\t\t// Tolerate failed edit chunk uploads, because they are fire-and-forget and can fail (e.g. the uploading client leaves before upload completes).\n\t\t\texpect(\n\t\t\t\tevents.unexpectedErrors.every(\n\t\t\t\t\t(e) => e.eventName === 'fluid:telemetry:FluidDataStoreRuntime:SharedTree:EditChunkUploadFailure'\n\t\t\t\t)\n\t\t\t).to.be.true;\n\t\t}\n\t\tconst trees = [\n\t\t\t...finalState.activeCollaborators.map(({ tree }) => tree),\n\t\t\t...finalState.passiveCollaborators.map(({ tree }) => tree),\n\t\t];\n\t\tfor (let i = 0; i < trees.length - 1; i++) {\n\t\t\texpect(trees[i].equals(trees[i + 1]));\n\t\t}\n\t}\n\n\treturn finalState as Required<FuzzTestState>;\n}\n\nexport function runSharedTreeFuzzTests(title: string): void {\n\t// Some useful tips for debugging fuzz tests:\n\t// - A JSON dump of the operation sequence can be written to disk by passing `true` for `saveOnFailure`.\n\t// - Different shared-tree instances can be distinguished (e.g. in logs) by using `tree.getRuntime().clientId`\n\tdescribe(title, () => {\n\t\tfunction runTest(\n\t\t\tgeneratorFactory: () => AsyncGenerator<Operation, FuzzTestState>,\n\t\t\tseed: number,\n\t\t\tsaveOnFailure?: boolean\n\t\t): void {\n\t\t\tit(`with seed ${seed}`, async () => {\n\t\t\t\tconst saveInfo =\n\t\t\t\t\tsaveOnFailure !== undefined\n\t\t\t\t\t\t? { filepath: join(directory, `test-history-${seed}.json`), saveOnFailure }\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (saveInfo !== undefined && !existsSync(directory)) {\n\t\t\t\t\tmkdirSync(directory);\n\t\t\t\t}\n\t\t\t\tawait performFuzzActions(generatorFactory(), seed + adjustSeed, true, saveInfo);\n\t\t\t}).timeout(10000);\n\t\t}\n\n\t\tfunction runMixedVersionTests(summarizeHistory: boolean, testsPerSuite: number, testLength: number): void {\n\t\t\tdescribe('using 0.0.2 and 0.1.1 trees', () => {\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\ttake(testLength, makeOpGenerator({ joinConfig: { summarizeHistory: [summarizeHistory] } })),\n\t\t\t\t\t\tseed\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdescribe('using only version 0.0.2', () => {\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\t\ttestLength,\n\t\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_0_2],\n\t\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tseed\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdescribe('using only version 0.1.1', () => {\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\t\ttestLength,\n\t\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_1_1],\n\t\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tseed\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdescribe('upgrading halfway through', () => {\n\t\t\t\tconst maximumActiveCollaborators = 10;\n\t\t\t\tconst maximumPassiveCollaborators = 5;\n\t\t\t\tconst editConfig: EditGenerationConfig = { maxTreeSize: 1000 };\n\t\t\t\tconst generatorFactory = () =>\n\t\t\t\t\tchain(\n\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\ttestLength / 2 - 1,\n\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\teditConfig,\n\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\tmaximumActiveCollaborators,\n\t\t\t\t\t\t\t\t\tmaximumPassiveCollaborators,\n\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_0_2],\n\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\tmaximumActiveCollaborators: maximumActiveCollaborators + 1,\n\t\t\t\t\t\t\t\t\tmaximumPassiveCollaborators,\n\t\t\t\t\t\t\t\t\twriteFormat: [WriteFormat.v0_1_1],\n\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\teditWeight: 0,\n\t\t\t\t\t\t\t\tjoinWeight: 1,\n\t\t\t\t\t\t\t\tleaveWeight: 0,\n\t\t\t\t\t\t\t\tsynchronizeWeight: 0,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttake(\n\t\t\t\t\t\t\ttestLength / 2,\n\t\t\t\t\t\t\tmakeOpGenerator({\n\t\t\t\t\t\t\t\teditConfig,\n\t\t\t\t\t\t\t\tjoinConfig: {\n\t\t\t\t\t\t\t\t\tmaximumActiveCollaborators,\n\t\t\t\t\t\t\t\t\tmaximumPassiveCollaborators,\n\t\t\t\t\t\t\t\t\tsummarizeHistory: [summarizeHistory],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\tfor (let seed = 0; seed < testsPerSuite; seed++) {\n\t\t\t\t\trunTest(generatorFactory, seed);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tconst testCount = 1;\n\t\tconst testLength = 200;\n\t\tdescribe('with no-history summarization', () => {\n\t\t\trunMixedVersionTests(false, testCount, testLength);\n\t\t});\n\n\t\tdescribe('with history summarization', () => {\n\t\t\trunMixedVersionTests(true, testCount, testLength);\n\t\t});\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedTreeTests.d.ts","sourceRoot":"","sources":["../../../src/test/utilities/SharedTreeTests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH,OAAO,EAeN,WAAW,EACX,MAAM,uBAAuB,CAAC;AAa/B,OAAO,EAGN,2BAA2B,EAC3B,wBAAwB,EAcxB,MAAM,iBAAiB,CAAC;AAazB;;;GAGG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,EACxB,qCAAqC,EAAE,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,2BAA2B,
|
|
1
|
+
{"version":3,"file":"SharedTreeTests.d.ts","sourceRoot":"","sources":["../../../src/test/utilities/SharedTreeTests.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH,OAAO,EAeN,WAAW,EACX,MAAM,uBAAuB,CAAC;AAa/B,OAAO,EAGN,2BAA2B,EAC3B,wBAAwB,EAcxB,MAAM,iBAAiB,CAAC;AAazB;;;GAGG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,EACxB,qCAAqC,EAAE,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,2BAA2B,QA0/C1G"}
|
|
@@ -23,6 +23,7 @@ import { InterningTreeCompressor } from '../../TreeCompressor';
|
|
|
23
23
|
import { SharedTreeEncoder_0_0_2, SharedTreeEncoder_0_1_1 } from '../../SharedTreeEncoder';
|
|
24
24
|
import { sequencedIdNormalizer } from '../../NodeIdUtilities';
|
|
25
25
|
import { convertNodeDataIds } from '../../IdConversion';
|
|
26
|
+
import { generateStableId, nilUuid } from '../../UuidUtilities';
|
|
26
27
|
import { buildLeaf, SimpleTestTree } from './TestNode';
|
|
27
28
|
import { TestFluidHandle, TestFluidSerializer } from './TestSerializer';
|
|
28
29
|
import { runSharedTreeUndoRedoTestSuite } from './UndoRedoTests';
|
|
@@ -216,18 +217,16 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
216
217
|
sharedTree.applyEdit(Change.build([], 0));
|
|
217
218
|
});
|
|
218
219
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// expect(tree.attributionId).to.equal(writeFormat === WriteFormat.v0_0_2 ? nilUuid : attributionId);
|
|
220
|
+
it('correctly reports attribution ID', () => {
|
|
221
|
+
const attributionId = generateStableId();
|
|
222
|
+
const { tree } = setUpTestSharedTree({ attributionId });
|
|
223
|
+
expect(tree.attributionId).to.equal(writeFormat === WriteFormat.v0_0_2 ? nilUuid : attributionId);
|
|
224
224
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
// expect(tree.attributeNodeId(id)).to.equal(writeFormat === WriteFormat.v0_0_2 ? nilUuid : attributionId);
|
|
225
|
+
it('correctly attributes node IDs', () => {
|
|
226
|
+
const attributionId = generateStableId();
|
|
227
|
+
const { tree } = setUpTestSharedTree({ attributionId });
|
|
228
|
+
const id = tree.generateNodeId();
|
|
229
|
+
expect(tree.attributeNodeId(id)).to.equal(writeFormat === WriteFormat.v0_0_2 ? nilUuid : attributionId);
|
|
231
230
|
});
|
|
232
231
|
runSharedTreeUndoRedoTestSuite(Object.assign({ localMode: true }, undoRedoOptions));
|
|
233
232
|
});
|
|
@@ -247,6 +246,32 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
247
246
|
localMode: false,
|
|
248
247
|
};
|
|
249
248
|
}
|
|
249
|
+
if (writeFormat === WriteFormat.v0_0_2) {
|
|
250
|
+
it('applies unversioned ops in the 0.0.2 format', () => {
|
|
251
|
+
var _a, _b, _c;
|
|
252
|
+
const { tree: sharedTree1, containerRuntimeFactory } = setUpTestSharedTree(tree1Options);
|
|
253
|
+
const { sharedTree: sharedTree2, testTree: testTree2 } = createSimpleTestTree(createSecondTreeOptions(containerRuntimeFactory));
|
|
254
|
+
containerRuntimeFactory.processAllMessages();
|
|
255
|
+
const originalPushMessage = containerRuntimeFactory.pushMessage.bind(containerRuntimeFactory);
|
|
256
|
+
containerRuntimeFactory.pushMessage = (msg) => {
|
|
257
|
+
// Drop the version property to replicate ops created before the version property existed
|
|
258
|
+
msg.contents.version = undefined;
|
|
259
|
+
originalPushMessage(msg);
|
|
260
|
+
};
|
|
261
|
+
// Ensure that an edit can be passed and processed between two trees as normal
|
|
262
|
+
sharedTree2.applyEdit(Change.delete(StableRange.only(testTree2.right)));
|
|
263
|
+
const getTestTreeRoot = (sharedTree) => new TreeNodeHandle(sharedTree.currentView, sharedTree.convertToNodeId(sharedTree2.convertToStableNodeId(testTree2.identifier)));
|
|
264
|
+
let root1 = getTestTreeRoot(sharedTree1);
|
|
265
|
+
let root2 = getTestTreeRoot(sharedTree2);
|
|
266
|
+
expect(Array.from(root1.traits[testTree2.right.traitLabel])).to.have.length(1);
|
|
267
|
+
expect(Array.from((_a = root2.traits[testTree2.right.traitLabel]) !== null && _a !== void 0 ? _a : [])).to.have.length(0);
|
|
268
|
+
containerRuntimeFactory.processAllMessages();
|
|
269
|
+
root1 = getTestTreeRoot(sharedTree1);
|
|
270
|
+
root2 = getTestTreeRoot(sharedTree2);
|
|
271
|
+
expect(Array.from((_b = root1.traits[testTree2.right.traitLabel]) !== null && _b !== void 0 ? _b : [])).to.have.length(0);
|
|
272
|
+
expect(Array.from((_c = root2.traits[testTree2.right.traitLabel]) !== null && _c !== void 0 ? _c : [])).to.have.length(0);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
250
275
|
it('should apply remote changes and converge', () => {
|
|
251
276
|
const { tree: sharedTree1, containerRuntimeFactory } = setUpTestSharedTree(tree1Options);
|
|
252
277
|
const { tree: sharedTree2 } = setUpTestSharedTree(createSecondTreeOptions(containerRuntimeFactory));
|
|
@@ -459,43 +484,22 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
459
484
|
const blobContents = await blobHandle.get();
|
|
460
485
|
expect(IsoBuffer.from(blobContents, 'utf8').toString()).to.equal(blobbedPayload);
|
|
461
486
|
});
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
// ...Change.insertTree(
|
|
479
|
-
// [buildLeaf(nodeId1)],
|
|
480
|
-
// StablePlace.atEndOf(testTrait(sharedTree1.currentView))
|
|
481
|
-
// )
|
|
482
|
-
// );
|
|
483
|
-
// containerRuntimeFactory.processAllMessages();
|
|
484
|
-
// expect(sharedTree2.attributeNodeId(sharedTree2.convertToNodeId(stableNodeId1))).to.equal(
|
|
485
|
-
// attributionId1
|
|
486
|
-
// );
|
|
487
|
-
// const nodeId2 = sharedTree2.generateNodeId();
|
|
488
|
-
// const stableNodeId2 = sharedTree2.convertToStableNodeId(nodeId1);
|
|
489
|
-
// sharedTree2.applyEdit(
|
|
490
|
-
// ...Change.insertTree(
|
|
491
|
-
// [buildLeaf(nodeId2)],
|
|
492
|
-
// StablePlace.atEndOf(testTrait(sharedTree2.currentView))
|
|
493
|
-
// )
|
|
494
|
-
// );
|
|
495
|
-
// containerRuntimeFactory.processAllMessages();
|
|
496
|
-
// expect(sharedTree1.attributeNodeId(sharedTree1.convertToNodeId(stableNodeId2))).to.equal(
|
|
497
|
-
// attributionId2
|
|
498
|
-
// );
|
|
487
|
+
it('can exchange attribution IDs', () => {
|
|
488
|
+
const attributionId1 = generateStableId();
|
|
489
|
+
const { tree: sharedTree1, containerRuntimeFactory } = setUpTestSharedTree(Object.assign(Object.assign({}, tree1Options), { attributionId: attributionId1 }));
|
|
490
|
+
const attributionId2 = generateStableId();
|
|
491
|
+
const { tree: sharedTree2 } = setUpTestSharedTree(Object.assign(Object.assign({}, createSecondTreeOptions(containerRuntimeFactory)), { attributionId: attributionId2 }));
|
|
492
|
+
containerRuntimeFactory.processAllMessages();
|
|
493
|
+
const nodeId1 = sharedTree1.generateNodeId();
|
|
494
|
+
const stableNodeId1 = sharedTree1.convertToStableNodeId(nodeId1);
|
|
495
|
+
sharedTree1.applyEdit(...Change.insertTree([buildLeaf(nodeId1)], StablePlace.atEndOf(testTrait(sharedTree1.currentView))));
|
|
496
|
+
containerRuntimeFactory.processAllMessages();
|
|
497
|
+
expect(sharedTree2.attributeNodeId(sharedTree2.convertToNodeId(stableNodeId1))).to.equal(attributionId1);
|
|
498
|
+
const nodeId2 = sharedTree2.generateNodeId();
|
|
499
|
+
const stableNodeId2 = sharedTree2.convertToStableNodeId(nodeId1);
|
|
500
|
+
sharedTree2.applyEdit(...Change.insertTree([buildLeaf(nodeId2)], StablePlace.atEndOf(testTrait(sharedTree2.currentView))));
|
|
501
|
+
containerRuntimeFactory.processAllMessages();
|
|
502
|
+
expect(sharedTree1.attributeNodeId(sharedTree1.convertToNodeId(stableNodeId2))).to.equal(attributionId2);
|
|
499
503
|
});
|
|
500
504
|
}
|
|
501
505
|
});
|
|
@@ -537,14 +541,9 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
537
541
|
}
|
|
538
542
|
const serialized = serialize(sharedTree.saveSummary(), testSerializer, testHandle);
|
|
539
543
|
const treeContent = JSON.parse(serialized);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
parsedTree = new SharedTreeEncoder_0_1_1(true).decodeSummary(treeContent);
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
parsedTree = new SharedTreeEncoder_0_0_2(true).decodeSummary(treeContent);
|
|
547
|
-
}
|
|
544
|
+
const parsedTree = writeFormat === WriteFormat.v0_1_1
|
|
545
|
+
? new SharedTreeEncoder_0_1_1(true).decodeSummary(treeContent, sharedTree.attributionId)
|
|
546
|
+
: new SharedTreeEncoder_0_0_2(true).decodeSummary(treeContent);
|
|
548
547
|
expect(parsedTree.currentTree).to.not.be.undefined;
|
|
549
548
|
const testRoot = assertArrayOfOne(assertNotUndefined((_a = parsedTree.currentTree) === null || _a === void 0 ? void 0 : _a.traits[testTree.traitLabel]));
|
|
550
549
|
expect(testRoot).to.not.be.undefined;
|
|
@@ -708,7 +707,7 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
708
707
|
it('is logged for invalid locally generated edits when those edits are sequenced', async () => {
|
|
709
708
|
const events = [];
|
|
710
709
|
const { sharedTree, testTree, containerRuntimeFactory } = createSimpleTestTree({
|
|
711
|
-
logger: { send: (event) => events.push(event) },
|
|
710
|
+
logger: { send: (event) => !event.eventName.includes('IdCompressor') && events.push(event) },
|
|
712
711
|
allowInvalid: true,
|
|
713
712
|
});
|
|
714
713
|
useFailedSequencedEditTelemetry(sharedTree);
|
|
@@ -725,7 +724,7 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
725
724
|
it('can be disabled and re-enabled', async () => {
|
|
726
725
|
const events = [];
|
|
727
726
|
const { sharedTree, testTree, containerRuntimeFactory } = createSimpleTestTree({
|
|
728
|
-
logger: { send: (event) => events.push(event) },
|
|
727
|
+
logger: { send: (event) => !event.eventName.includes('IdCompressor') && events.push(event) },
|
|
729
728
|
allowInvalid: true,
|
|
730
729
|
});
|
|
731
730
|
const { disable } = useFailedSequencedEditTelemetry(sharedTree);
|
|
@@ -750,7 +749,7 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
750
749
|
it('is not logged for valid edits', async () => {
|
|
751
750
|
const events = [];
|
|
752
751
|
const { sharedTree, testTree, containerRuntimeFactory } = createSimpleTestTree({
|
|
753
|
-
logger: { send: (event) => events.push(event) },
|
|
752
|
+
logger: { send: (event) => !event.eventName.includes('IdCompressor') && events.push(event) },
|
|
754
753
|
});
|
|
755
754
|
useFailedSequencedEditTelemetry(sharedTree);
|
|
756
755
|
sharedTree.applyEdit(...Change.insertTree(testTree.buildLeaf(), StablePlace.after(testTree.left)));
|
|
@@ -761,7 +760,7 @@ export function runSharedTreeOperationsTests(title, writeFormat, setUpTestShared
|
|
|
761
760
|
it('is not logged for remote edits', async () => {
|
|
762
761
|
const events = [];
|
|
763
762
|
const { sharedTree: sharedTree1, containerRuntimeFactory } = createSimpleTestTree({
|
|
764
|
-
logger: { send: (event) => events.push(event) },
|
|
763
|
+
logger: { send: (event) => !event.eventName.includes('IdCompressor') && events.push(event) },
|
|
765
764
|
allowInvalid: true,
|
|
766
765
|
localMode: false,
|
|
767
766
|
});
|