debugged some of the special cases of Utils.receivedOp & found some bugs

This commit is contained in:
Kevin Jahns 2016-06-28 16:23:02 +02:00
parent 81e72126ce
commit 3dc67e075b
2 changed files with 42 additions and 41 deletions

@ -88,7 +88,7 @@ g.getRandomString = getRandomString
function * applyTransactions (relAmount, numberOfTransactions, objects, users, transactions, noReconnect) {
for (var i = 0; i < numberOfTransactions * relAmount + 1; i++) {
var r = Math.random()
if (r > 0.9) {
if (r > 0.95) {
// 10% chance of toggling concurrent user interactions.
// There will be an artificial delay until ops can be executed by the type,
// therefore, operations of the database will be (pre)transformed until user operations arrive

@ -149,7 +149,6 @@ module.exports = function (Y /* : any*/) {
if (dStart < iEnd) {
if (iEnd < dEnd) {
// Case 1
debugger
// remove the right part of i's content
i.content.splice(dStart - iStart)
// remove the start of d's deletion
@ -176,7 +175,6 @@ module.exports = function (Y /* : any*/) {
} else if (dStart === iStart) {
if (iEnd < dEnd) {
// Case 4
debugger
d.length = dEnd - iEnd
d.target = [d.target[0], iEnd]
i.content = []
@ -192,6 +190,8 @@ module.exports = function (Y /* : any*/) {
return
}
} else { // (dStart < iStart)
if (iStart < dEnd) {
// they overlap
/*
7) iii
ddddddd
@ -220,20 +220,21 @@ module.exports = function (Y /* : any*/) {
return
} else if (iEnd === dEnd) {
// Case 8
debugger
self.waiting.splice(w, 1)
return
w--
d.length -= iLength
continue
} else { // dEnd < iEnd
// Case 9
debugger
d.length = iStart - dStart
i.content.splice(dEnd - iStart)
i.content.splice(0, dEnd - iStart)
i.id = [i.id[0], dEnd]
continue
}
}
}
}
}
// finished with remaining operations
self.waiting.push(d)
}