debugged some of the special cases of Utils.receivedOp & found some bugs
This commit is contained in:
parent
81e72126ce
commit
3dc67e075b
@ -88,7 +88,7 @@ g.getRandomString = getRandomString
|
|||||||
function * applyTransactions (relAmount, numberOfTransactions, objects, users, transactions, noReconnect) {
|
function * applyTransactions (relAmount, numberOfTransactions, objects, users, transactions, noReconnect) {
|
||||||
for (var i = 0; i < numberOfTransactions * relAmount + 1; i++) {
|
for (var i = 0; i < numberOfTransactions * relAmount + 1; i++) {
|
||||||
var r = Math.random()
|
var r = Math.random()
|
||||||
if (r > 0.9) {
|
if (r > 0.95) {
|
||||||
// 10% chance of toggling concurrent user interactions.
|
// 10% chance of toggling concurrent user interactions.
|
||||||
// There will be an artificial delay until ops can be executed by the type,
|
// 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
|
// therefore, operations of the database will be (pre)transformed until user operations arrive
|
||||||
|
81
src/Utils.js
81
src/Utils.js
@ -149,7 +149,6 @@ module.exports = function (Y /* : any*/) {
|
|||||||
if (dStart < iEnd) {
|
if (dStart < iEnd) {
|
||||||
if (iEnd < dEnd) {
|
if (iEnd < dEnd) {
|
||||||
// Case 1
|
// Case 1
|
||||||
debugger
|
|
||||||
// remove the right part of i's content
|
// remove the right part of i's content
|
||||||
i.content.splice(dStart - iStart)
|
i.content.splice(dStart - iStart)
|
||||||
// remove the start of d's deletion
|
// remove the start of d's deletion
|
||||||
@ -176,7 +175,6 @@ module.exports = function (Y /* : any*/) {
|
|||||||
} else if (dStart === iStart) {
|
} else if (dStart === iStart) {
|
||||||
if (iEnd < dEnd) {
|
if (iEnd < dEnd) {
|
||||||
// Case 4
|
// Case 4
|
||||||
debugger
|
|
||||||
d.length = dEnd - iEnd
|
d.length = dEnd - iEnd
|
||||||
d.target = [d.target[0], iEnd]
|
d.target = [d.target[0], iEnd]
|
||||||
i.content = []
|
i.content = []
|
||||||
@ -192,44 +190,47 @@ module.exports = function (Y /* : any*/) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else { // (dStart < iStart)
|
} else { // (dStart < iStart)
|
||||||
/*
|
if (iStart < dEnd) {
|
||||||
7) iii
|
// they overlap
|
||||||
ddddddd
|
/*
|
||||||
--> remove i, create and apply two d with checkDelete(d) (**)
|
7) iii
|
||||||
8) iiiii
|
ddddddd
|
||||||
ddddddd
|
--> remove i, create and apply two d with checkDelete(d) (**)
|
||||||
--> remove i, modify d (**)
|
8) iiiii
|
||||||
9) iiiii
|
ddddddd
|
||||||
ddddd
|
--> remove i, modify d (**)
|
||||||
--> modify i and d
|
9) iiiii
|
||||||
*/
|
ddddd
|
||||||
if (iEnd < dEnd) {
|
--> modify i and d
|
||||||
// Case 7
|
*/
|
||||||
debugger
|
if (iEnd < dEnd) {
|
||||||
self.waiting.splice(w, 1)
|
// Case 7
|
||||||
checkDelete({
|
debugger
|
||||||
target: [d.target[0], dStart],
|
self.waiting.splice(w, 1)
|
||||||
length: iStart - dStart,
|
checkDelete({
|
||||||
struct: 'Delete'
|
target: [d.target[0], dStart],
|
||||||
})
|
length: iStart - dStart,
|
||||||
checkDelete({
|
struct: 'Delete'
|
||||||
target: [d.target[0], iEnd],
|
})
|
||||||
length: iEnd - dEnd,
|
checkDelete({
|
||||||
struct: 'Delete'
|
target: [d.target[0], iEnd],
|
||||||
})
|
length: iEnd - dEnd,
|
||||||
return
|
struct: 'Delete'
|
||||||
} else if (iEnd === dEnd) {
|
})
|
||||||
// Case 8
|
return
|
||||||
debugger
|
} else if (iEnd === dEnd) {
|
||||||
self.waiting.splice(w, 1)
|
// Case 8
|
||||||
return
|
self.waiting.splice(w, 1)
|
||||||
} else { // dEnd < iEnd
|
w--
|
||||||
// Case 9
|
d.length -= iLength
|
||||||
debugger
|
continue
|
||||||
d.length = iStart - dStart
|
} else { // dEnd < iEnd
|
||||||
i.content.splice(dEnd - iStart)
|
// Case 9
|
||||||
i.id = [i.id[0], dEnd]
|
d.length = iStart - dStart
|
||||||
continue
|
i.content.splice(0, dEnd - iStart)
|
||||||
|
i.id = [i.id[0], dEnd]
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user