summary refs log tree commit diff
path: root/tests/test_state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-08 20:13:27 +0100
committerErik Johnston <erik@matrix.org>2014-09-08 20:13:27 +0100
commit942d8412c49a1d481f0bedd189eb1598629b103c (patch)
treead199a4bd331f2594b98b0094f070a8e7bc68d9c /tests/test_state.py
parentAdded number of users in recent rooms. (diff)
downloadsynapse-942d8412c49a1d481f0bedd189eb1598629b103c.tar.xz
Handle the case where we don't have a common ancestor
Diffstat (limited to '')
-rw-r--r--tests/test_state.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_state.py b/tests/test_state.py
index 4512475ebd..a9fc3fb85c 100644
--- a/tests/test_state.py
+++ b/tests/test_state.py
@@ -441,6 +441,30 @@ class StateTestCase(unittest.TestCase):
         self.assertEqual(1, self.persistence.update_current_state.call_count)
 
     @defer.inlineCallbacks
+    def test_no_common_ancestor(self):
+        # We do a direct overwriting of the old state, i.e., the new state
+        # points to the old state.
+
+        old_pdu = new_fake_pdu_entry("A", "test", "mem", "x", None, 5)
+        new_pdu = new_fake_pdu_entry("B", "test", "mem", "x", None, 10)
+
+        self.persistence.get_unresolved_state_tree.return_value = (
+            (ReturnType([new_pdu], [old_pdu]), None)
+        )
+
+        is_new = yield self.state.handle_new_state(new_pdu)
+
+        self.assertTrue(is_new)
+
+        self.persistence.get_unresolved_state_tree.assert_called_once_with(
+            new_pdu
+        )
+
+        self.assertEqual(1, self.persistence.update_current_state.call_count)
+
+        self.assertFalse(self.replication.get_pdu.called)
+
+    @defer.inlineCallbacks
     def test_new_event(self):
         event = Mock()
         event.event_id = "12123123@test"