Skip to content
Browse files

[fix #188] heisenbug in synchronization

After a conflict the server always sents a RAW response because
the server didn't change the status of the paper and considered
that the conflict was not managed.

The bug was "deltaOk == true" instead of "deltaOk = true".
  • Loading branch information
tdurieux committed Mar 23, 2015
1 parent c73d4c4 commit faa2c69abf3c9d37c2efc65c9e6a56307c0e4a97
@@ -215,7 +215,7 @@ class SyncActor(
view.deltaOk = false
} else if (revision == view.serverShadowRevision) {
// The version number matches the shadow, proceed.
view.deltaOk == true
view.deltaOk = true

action match {
@@ -211,6 +211,30 @@ class SyncActorSpec extends TestKit(ActorSystem("SyncActorSpec"))


scenario("a user sends a synchronization command with invalid server revision on existing file and accepts the raw response") {

Given("a synchronization actor, already used by a user")
val syncActor = TestActorRef(new SyncActor(config, "paperId", store, dmp, logger))
syncActor ! SyncSession("user", "paperId", List(SyncCommand("testPaper", 0, Delta(0, List(Add("Hello")), false))))
expectMsg(SyncSession("user", "paperId", List(SyncCommand("testPaper", 1, Delta(0, List(Equality(5)), false)))))

And("a synchronization command with invalid server revision")
val request = SyncSession("user", "paperId", List(SyncCommand("testPaper", 51, Delta(0, List(), false))))

When("he sends the message")
syncActor ! request

Then("the actor should detect the invalid revision and send Raw version")
expectMsg(SyncSession("user", "paperId", List(SyncCommand("testPaper", 2, Raw(1, "Hello", true)))))

Then("the user accepts the change and sends a delta request")
val request2 = SyncSession("user", "paperId", List(SyncCommand("testPaper", 1, Delta(2, List(Equality(5)), false))))
syncActor ! request2

Then("the actor should process the delta and sends back a response")
expectMsg(SyncSession("user", "paperId", List(SyncCommand("testPaper", 3, Delta(1, List(Equality(5)), false)))))

scenario("persists an existing file on disk") {

Given("a synchronization actor")

0 comments on commit faa2c69

Please sign in to comment.