Permalink
Browse files

Add use case that produces "empty context diff" error

  • Loading branch information...
1 parent a97c1d5 commit e87817deb9a65fbfd8f0617529f8655c1eda44fa @ccotter ccotter committed Nov 27, 2012
Showing with 38 additions and 1 deletion.
  1. +37 −0 examples/possible_bug/buggy.js
  2. +1 −1 src/coweb/jsoe/ContextVector.js
@@ -0,0 +1,37 @@
+
+var OTEngine = require("coweb-jsoe").OTEngine;
+
+var mod = new OTEngine(0);
+var ot1 = new OTEngine(1);
+var ot2 = new OTEngine(2);
+
+/*
+st1 = mod.syncOutbound();
+st2 = ot1.syncOutbound();
+st3 = ot2.syncOutbound();
+
+mod.syncInbound(1, st2);
+mod.syncInbound(2, st3);
+ot1.syncInbound(0, st1);
+ot1.syncInbound(2, st3);
+ot2.syncInbound(0, st1);
+ot2.syncInbound(1, st2);
+*/
+
+op2 = mod.createOp("change", {}, "insert", 0);
+op1 = ot1.createOp("change", {}, "insert", 1);
+op1order = 0;
+op2order = 1;
+
+s1 = ot1.localEvent(op1);
+mod.remoteEvent(op1order, s1);
+s2 = mod.localEvent(op2);
+
+console.log(s1.sites);
+console.log(s2.sites);
+
+console.log("ot2:",ot2._engine.cvt.getState());
+ot2.remoteEvent(op2order, s2);
+console.log("ot2:",ot2._engine.cvt.getState());
+ot2.remoteEvent(op1order, s1);
+
@@ -97,7 +97,7 @@ define([
for(var i=0; i < this.sites.length; i++) {
var a = this.getSeqForSite(i);
var b = cv.getSeqForSite(i);
- if(a-b > 0) {
+ if(a > b) {
cd.addRange(i, b+1, a+1);
}
}

0 comments on commit e87817d

Please sign in to comment.