summary refs log tree commit diff
path: root/tests/handlers/test_federation.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-11 17:01:27 +0000
committerErik Johnston <erik@matrix.org>2014-12-11 17:01:27 +0000
commitd3eb12c7b8292f2879e5aa11cb5ffec05ce2a3a5 (patch)
tree57dd92aef7bcfe82b137b895135e24d2072bc5f4 /tests/handlers/test_federation.py
parentFix room creation test (diff)
downloadsynapse-d3eb12c7b8292f2879e5aa11cb5ffec05ce2a3a5.tar.xz
Fix federation test
Diffstat (limited to '')
-rw-r--r--tests/handlers/test_federation.py42
1 files changed, 24 insertions, 18 deletions
diff --git a/tests/handlers/test_federation.py b/tests/handlers/test_federation.py
index fae33716a3..91f7351087 100644
--- a/tests/handlers/test_federation.py
+++ b/tests/handlers/test_federation.py
@@ -20,7 +20,7 @@ from synapse.api.events.room import (
     MessageEvent,
 )
 
-from synapse.api.events import SynapseEvent
+from synapse.events import FrozenEvent
 from synapse.handlers.federation import FederationHandler
 from synapse.server import HomeServer
 
@@ -37,7 +37,7 @@ class FederationTestCase(unittest.TestCase):
         self.mock_config.signing_key = [MockKey()]
 
         self.state_handler = NonCallableMock(spec_set=[
-            "annotate_event_with_state",
+            "annotate_context_with_state",
         ])
 
         self.auth = NonCallableMock(spec_set=[
@@ -78,36 +78,42 @@ class FederationTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def test_msg(self):
-        pdu = SynapseEvent(
-            type=MessageEvent.TYPE,
-            room_id="foo",
-            content={"msgtype": u"fooo"},
-            origin_server_ts=0,
-            event_id="$a:b",
-            user_id="@a:b",
-            origin="b",
-            auth_events=[],
-            hashes={"sha256":"AcLrgtUIqqwaGoHhrEvYG1YLDIsVPYJdSRGhkp3jJp8"},
-        )
+        pdu = FrozenEvent({
+            "type": MessageEvent.TYPE,
+            "room_id": "foo",
+            "content": {"msgtype": u"fooo"},
+            "origin_server_ts": 0,
+            "event_id": "$a:b",
+            "user_id":"@a:b",
+            "origin": "b",
+            "auth_events": [],
+            "hashes": {"sha256":"AcLrgtUIqqwaGoHhrEvYG1YLDIsVPYJdSRGhkp3jJp8"},
+        })
 
         self.datastore.persist_event.return_value = defer.succeed(None)
         self.datastore.get_room.return_value = defer.succeed(True)
         self.auth.check_host_in_room.return_value = defer.succeed(True)
 
-        def annotate(ev, old_state=None):
-            ev.old_state_events = []
+        def annotate(ev, context, old_state=None):
+            context.current_state = {}
+            context.auth_events = {}
             return defer.succeed(False)
-        self.state_handler.annotate_event_with_state.side_effect = annotate
+        self.state_handler.annotate_context_with_state.side_effect = annotate
 
         yield self.handlers.federation_handler.on_receive_pdu(
             "fo", pdu, False
         )
 
         self.datastore.persist_event.assert_called_once_with(
-            ANY, is_new_state=False, backfilled=False, current_state=None
+            ANY,
+            is_new_state=True,
+            backfilled=False,
+            current_state=None,
+            context=ANY,
         )
 
-        self.state_handler.annotate_event_with_state.assert_called_once_with(
+        self.state_handler.annotate_context_with_state.assert_called_once_with(
+            ANY,
             ANY,
             old_state=None,
         )