fixed late sync with deletions

This commit is contained in:
Kevin Jahns 2015-07-25 23:58:57 +00:00
parent 56165a3c10
commit 81c601c65f
2 changed files with 24 additions and 18 deletions

View File

@ -144,6 +144,7 @@
this.eventHandler.addUserEventListener(f)
}
* _changed (transaction, op) {
if (!op.deleted) {
if (op.struct === 'Insert') {
var l = op.left
var left
@ -159,6 +160,7 @@
this.eventHandler.receivedOp(op)
}
}
}
Y.Array = new CustomType({
class: YArray,

View File

@ -1,7 +1,7 @@
/* global createUsers, wait, Y, compareAllUsers, getRandomNumber, applyRandomTransactions */
/* eslint-env browser,jasmine */
var numberOfYArrayTests = 10
var numberOfYArrayTests = 100
describe('Array Type', function () {
var y1, y2, y3, yconfig1, yconfig2, yconfig3, flushAll
@ -95,6 +95,17 @@ describe('Array Type', function () {
expect(l1.toArray()).toEqual(l2.toArray())
done()
})
it('Handles deletions in late sync (2)', async function (done) {
var l1, l2
l1 = await y1.set('Array', Y.Array)
await flushAll()
l2 = await y2.get('Array')
l1.insert(0, ['x', 'y'])
l1.delete(0, 2)
await flushAll()
expect(l1.toArray()).toEqual(l2.toArray())
done()
})
it('Basic insert. Then delete the whole array', async function (done) {
var l1, l2, l3
l1 = await y1.set('Array', Y.Array)
@ -208,13 +219,6 @@ describe('Array Type', function () {
done()
})
it(`succeed after ${numberOfYArrayTests} actions`, async function (done) {
while (this.users.length > 2) {
this.users.pop().disconnect()
this.arrays.pop()
}
for (var u of this.users) {
u.connector.debug = true
}
await applyRandomTransactions(this.users, this.arrays, randomArrayTransactions, numberOfYArrayTests)
await flushAll()
await compareArrayValues(this.arrays)