choose rencoding version at random
This commit is contained in:
parent
076d550dfa
commit
3406247a3e
@ -45,6 +45,13 @@ export let DefaultDSDecoder = DSDecoderV1
|
||||
export let DefaultUpdateEncoder = UpdateEncoderV1
|
||||
export let DefaultUpdateDecoder = UpdateDecoderV1
|
||||
|
||||
export const useV1Encoding = () => {
|
||||
DefaultDSEncoder = DSEncoderV1
|
||||
DefaultDSDecoder = DSDecoderV1
|
||||
DefaultUpdateEncoder = UpdateEncoderV1
|
||||
DefaultUpdateDecoder = UpdateDecoderV1
|
||||
}
|
||||
|
||||
export const useV2Encoding = () => {
|
||||
DefaultDSEncoder = DSEncoderV2
|
||||
DefaultDSDecoder = DSDecoderV2
|
||||
|
@ -4,6 +4,8 @@ import {
|
||||
createDeleteSetFromStructStore,
|
||||
getStateVector,
|
||||
Item,
|
||||
useV1Encoding,
|
||||
useV2Encoding,
|
||||
DeleteItem, DeleteSet, StructStore, Doc // eslint-disable-line
|
||||
} from '../src/internals.js'
|
||||
|
||||
@ -240,6 +242,13 @@ export const init = (tc, { users = 5 } = {}, initTestObject) => {
|
||||
users: []
|
||||
}
|
||||
const gen = tc.prng
|
||||
// choose an encoding approach at random
|
||||
if (prng.bool(gen)) {
|
||||
useV2Encoding()
|
||||
} else {
|
||||
useV1Encoding()
|
||||
}
|
||||
|
||||
const testConnector = new TestConnector(gen)
|
||||
result.testConnector = testConnector
|
||||
for (let i = 0; i < users; i++) {
|
||||
@ -253,6 +262,7 @@ export const init = (tc, { users = 5 } = {}, initTestObject) => {
|
||||
}
|
||||
testConnector.syncAll()
|
||||
result.testObjects = result.users.map(initTestObject || (() => null))
|
||||
useV1Encoding()
|
||||
return /** @type {any} */ (result)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user