Skip to content
Snippets Groups Projects
test_event_federation.py 37.1 KiB
Newer Older
  • Learn to ignore specific revisions
  •             )
            )
            self.get_success(
                self.store.record_event_failed_pull_attempt(
                    room_id, "insertion_eventA", "fake cause"
                )
            )
            self.get_success(
                self.store.record_event_failed_pull_attempt(
                    room_id, "insertion_eventA", "fake cause"
                )
            )
            self.get_success(
                self.store.record_event_failed_pull_attempt(
                    room_id, "insertion_eventA", "fake cause"
                )
            )
            self.get_success(
                self.store.record_event_failed_pull_attempt(
                    room_id, "insertion_eventA", "fake cause"
                )
            )
    
            # Now advance time by 2 hours and we should only be able to see
            # "insertion_eventB" because we have waited long enough for the single
            # attempt (2^1 hours) but we still shouldn't see "insertion_eventA"
            # because we haven't waited long enough for this many attempts.
            self.reactor.advance(datetime.timedelta(hours=2).total_seconds())
    
            # Make sure that "insertion_eventA" is not in the list because we've
            # already attempted many times
            backfill_points = self.get_success(
                self.store.get_insertion_event_backward_extremities_in_room(room_id)
            )
            backfill_event_ids = [backfill_point[0] for backfill_point in backfill_points]
            self.assertListEqual(backfill_event_ids, ["insertion_eventB"])
    
            # Now advance time by 20 hours (above 2^4 because we made 4 attemps) and
            # see if we can now backfill it
            self.reactor.advance(datetime.timedelta(hours=20).total_seconds())
    
            # Try at "insertion_eventA" again after we advanced enough time and we
            # should see "insertion_eventA" again
            backfill_points = self.get_success(
                self.store.get_insertion_event_backward_extremities_in_room(room_id)
            )
            backfill_event_ids = [backfill_point[0] for backfill_point in backfill_points]
            self.assertListEqual(
                backfill_event_ids, ["insertion_eventB", "insertion_eventA"]
            )
    
    
    
    @attr.s
    class FakeEvent:
        event_id = attr.ib()
        room_id = attr.ib()
        auth_events = attr.ib()
    
        type = "foo"
        state_key = "foo"
    
        internal_metadata = _EventInternalMetadata({})
    
        def auth_event_ids(self):
            return self.auth_events
    
        def is_state(self):
            return True