async def test_replay_diverging_replay(event_loop, mock_bookkeeper, controlled_connections): r = Replay.build(1, mock_bookkeeper, replay_config(config_dict)) conns = [controlled_connections() for _ in range(0, 6)] conn_work = [do_write(c, div, 4000) for c, div in zip(conns, diverging_1)] read_conn = controlled_connections() head = ConnectionHeader(ConnectionHeader.Type.WRITER, 1, "foo") read_head = ConnectionHeader(ConnectionHeader.Type.READER, 1, "foo") r_work = [r.handle_connection(head, c) for c in conns] w_work = [r.handle_connection(read_head, read_conn)] # Version 5 is the best for this replay. # We don't require picking a specific header, its dicts have unspecified # order :/ def check_saved(_, s): body_offset = diverging_1[5].header_size assert s.data.bytes() == diverging_1[5].data[body_offset:] mock_bookkeeper.save_replay.side_effect = check_saved await asyncio.gather(*(conn_work + r_work + w_work)) await r.wait_for_ended() # Our current strategy should find replay 5, ignoring header. read_data = read_conn._get_mock_write_data()[diverging_1[5].header_size:] assert read_data == diverging_1[5].main_data
def build(cls, bookkeeper, config): return cls(lambda game_id: Replay.build(game_id, bookkeeper, config))
def test_replay_init(mock_bookkeeper): Replay.build(1, mock_bookkeeper, **config)
def test_replay_init(mock_bookkeeper): Replay.build(1, mock_bookkeeper, replay_config(config_dict))
def build(cls, bookkeeper, **kwargs): return cls(lambda game_id: Replay.build(game_id, bookkeeper, **kwargs))