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,19 +144,21 @@
this.eventHandler.addUserEventListener(f)
}
* _changed (transaction, op) {
if (op.struct === 'Insert') {
var l = op.left
var left
while (l != null) {
left = yield* transaction.getOperation(l)
if (!left.deleted) {
break
if (!op.deleted) {
if (op.struct === 'Insert') {
var l = op.left
var left
while (l != null) {
left = yield* transaction.getOperation(l)
if (!left.deleted) {
break
}
l = left.left
}
l = left.left
op.left = l
}
op.left = l
this.eventHandler.receivedOp(op)
}
this.eventHandler.receivedOp(op)
}
}

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)