fixed some issues in random tests

This commit is contained in:
Kevin Jahns 2019-03-06 13:29:16 +01:00
parent 99e3e95a00
commit 76b7d0b651
6 changed files with 1987 additions and 256 deletions

2141
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,13 +9,13 @@
"test": "npm run lint && npm run dist && node ./dist/tests.js",
"dist": "rm -rf dist examples/build && PRODUCTION=1 rollup -c",
"watch": "rollup -wc",
"debug": "concurrently 'npm run watch' 'cutest-serve dist/tests.js -o'",
"lint": "standard",
"docs": "rm -rf docs; jsdoc --configure ./.jsdoc.json --verbose --readme ./README.v13.md --package ./package.json || true",
"serve-docs": "npm run docs && serve ./docs/",
"postversion": "npm run dist",
"websocket-server": "node ./provider/websocket/server.js",
"now-start": "npm run websocket-server"
"debug": "concurrently 'live-server --port=3443 --entry-file=test.html' 'npm run watch'",
"trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.js",
"trace-opt": "clear && rollup -c && node --trace-opt dist/test.js"
},
"files": [
"dist/*",
@ -65,6 +65,7 @@
"esdoc-standard-plugin": "^1.0.0",
"esm": "^3.2.6",
"jsdoc": "^3.5.5",
"live-server": "^1.2.1",
"prosemirror-example-setup": "^1.0.1",
"prosemirror-schema-basic": "^1.0.0",
"prosemirror-state": "^1.2.2",

View File

@ -5,6 +5,7 @@
import { getStruct } from 'y-protocols/sync.js'
import * as decoding from 'funlib/decoding.js'
import { GC } from '../structs/GC.js'
import { Delete } from '../structs/Delete.js'
import { Y } from '../utils/Y.js' // eslint-disable-line
import { Item } from '../structs/Item.js' // eslint-disable-line
@ -56,6 +57,9 @@ function _integrateRemoteStructHelper (y, struct) {
decoder.pos = oldPos
if (missing.length === 0) {
y._readyToIntegrate.push(missingDef.struct)
// TODO: sorting should be optimized
// Sorting because deletes may change the origin of ops
y._readyToIntegrate.sort((a, b) => a.constructor === b.constructor ? 0 : (a.constructor === Delete ? 1 : -1))
} else {
// TODO: throw error here
}
@ -84,6 +88,7 @@ export const integrateRemoteStructs = (decoder, y) => {
let decoderPos = decoder.pos
let missing = struct._fromBinary(y, decoder)
if (missing.length === 0) {
y._readyToIntegrate.sort((a, b) => a.constructor === b.constructor ? 0 : (a.constructor === Delete ? 1 : -1))
while (struct != null) {
_integrateRemoteStructHelper(y, struct)
struct = y._readyToIntegrate.shift()
@ -121,6 +126,7 @@ export const integrateRemoteStruct = (decoder, y) => {
let decoderPos = decoder.pos
let missing = struct._fromBinary(y, decoder)
if (missing.length === 0) {
y._readyToIntegrate.sort((a, b) => a.constructor === b.constructor ? 0 : (a.constructor === Delete ? 1 : -1))
while (struct != null) {
_integrateRemoteStructHelper(y, struct)
struct = y._readyToIntegrate.shift()

View File

@ -145,7 +145,7 @@ export class TestConnector {
}
const encoder = encoding.createEncoder()
receiver.mMux(() => {
console.log('receive (' + sender.userID + '->' + receiver.userID + '):\n', syncProtocol.stringifySyncMessage(decoding.createDecoder(m), receiver))
// console.log('receive (' + sender.userID + '->' + receiver.userID + '):\n', syncProtocol.stringifySyncMessage(decoding.createDecoder(m), receiver))
// do not publish data created when this function is executed (could be ss2 or update message)
syncProtocol.readSyncMessage(decoding.createDecoder(m), encoder, receiver)
})

View File

@ -108,7 +108,7 @@ export class TestYInstance extends Y.Y {
/**
* Keeps track of TestYInstances.
*
* The TestYInstances add/remove themselves from the list of connections maintained in this object.
* The TestYInstances add/remove themselves from the list of connections maiained in this object.
* I think it makes sense. Deal with it.
*/
export class TestConnector {
@ -330,7 +330,7 @@ export const compare = users => {
return data
})
for (var i = 0; i < data.length - 1; i++) {
t.describe(`Comparing user${i} with user${i + 1}`)
// t.describe(`Comparing user${i} with user${i + 1}`)
t.compare(userArrayValues[i].length, users[i].get('array').length, 'array length correctly computed')
t.compare(userArrayValues[i], userArrayValues[i + 1], 'array types')
t.compare(userMapValues[i], userMapValues[i + 1], 'map types')

View File

@ -276,59 +276,54 @@ let arrayTransactions = [
}
]
export const testRepeatGeneratingYarrayTests20 = tc => applyRandomTests(tc, arrayTransactions, 20)
export const testRepeatGeneratingYarrayTests20 = tc => {
applyRandomTests(tc, arrayTransactions, 20)
}
/*
export const testRepeatGeneratingYarrayTests40 = tc => {
applyRandomTests(tc, arrayTransactions, 40)
}
test('y-array: Random tests (20)', async function randomArray20 (t) {
await applyRandomTests(t, arrayTransactions, 20)
})
export const testRepeatGeneratingYarrayTests42 = tc => {
applyRandomTests(tc, arrayTransactions, 42)
}
test('y-array: Random tests (42)', async function randomArray42 (t) {
await applyRandomTests(t, arrayTransactions, 42)
})
export const testRepeatGeneratingYarrayTests43 = tc => {
applyRandomTests(tc, arrayTransactions, 43)
}
test('y-array: Random tests (43)', async function randomArray43 (t) {
await applyRandomTests(t, arrayTransactions, 43)
})
export const testRepeatGeneratingYarrayTests44 = tc => {
applyRandomTests(tc, arrayTransactions, 44)
}
test('y-array: Random tests (44)', async function randomArray44 (t) {
await applyRandomTests(t, arrayTransactions, 44)
})
export const testRepeatGeneratingYarrayTests45 = tc => {
applyRandomTests(tc, arrayTransactions, 45)
}
test('y-array: Random tests (45)', async function randomArray45 (t) {
await applyRandomTests(t, arrayTransactions, 45)
})
export const testRepeatGeneratingYarrayTests46 = tc => {
applyRandomTests(tc, arrayTransactions, 46)
}
test('y-array: Random tests (46)', async function randomArray46 (t) {
await applyRandomTests(t, arrayTransactions, 46)
})
export const testRepeatGeneratingYarrayTests300 = tc => {
applyRandomTests(tc, arrayTransactions, 300)
}
test('y-array: Random tests (47)', async function randomArray47 (t) {
await applyRandomTests(t, arrayTransactions, 47)
})
export const testRepeatGeneratingYarrayTests400 = tc => {
applyRandomTests(tc, arrayTransactions, 400)
}
test('y-array: Random tests (300)', async function randomArray300 (t) {
await applyRandomTests(t, arrayTransactions, 200)
})
export const testRepeatGeneratingYarrayTests500 = tc => {
applyRandomTests(tc, arrayTransactions, 500)
}
test('y-array: Random tests (500)', async function randomArray500 (t) {
await applyRandomTests(t, arrayTransactions, 300)
})
export const testRepeatGeneratingYarrayTests600 = tc => {
applyRandomTests(tc, arrayTransactions, 600)
}
test('y-array: Random tests (600)', async function randomArray600 (t) {
await applyRandomTests(t, arrayTransactions, 400)
})
export const testRepeatGeneratingYarrayTests1000 = tc => {
applyRandomTests(tc, arrayTransactions, 1000)
}
test('y-array: Random tests (700)', async function randomArray700 (t) {
await applyRandomTests(t, arrayTransactions, 500)
})
test('y-array: Random tests (1000)', async function randomArray1000 (t) {
await applyRandomTests(t, arrayTransactions, 1000)
})
test('y-array: Random tests (1800)', async function randomArray1800 (t) {
await applyRandomTests(t, arrayTransactions, 2000)
})
*/
export const testRepeatGeneratingYarrayTests1800 = tc => {
applyRandomTests(tc, arrayTransactions, 1800)
}