def send(room: Room) -> None: while True: data = {"monotonic_start": time.monotonic()} data_encoded = json.dumps(data) with logtime(MESSAGE, room_id=room.room_id): room.send_text(data_encoded)
def make_message(convert_to_hex: bool = False, overwrite_data=None): room = Room(None, "!roomID:server") if not overwrite_data: message = SecretRequest( message_identifier=random.randint(0, UINT64_MAX), payment_identifier=1, secrethash=factories.UNIT_SECRETHASH, amount=1, expiration=10, ) message.sign(LocalSigner(factories.HOP1_KEY)) data = message.encode() if convert_to_hex: data = "0x" + data.hex() else: data = json.dumps(message.to_dict()) else: data = overwrite_data event = dict(type="m.room.message", sender=USERID1, content={ "msgtype": "m.text", "body": data }) return room, event
def make_message(convert_to_hex: bool = False, overwrite_data=None): from matrix_client.room import Room room = Room(None, '!roomID:server') if not overwrite_data: message = SecretRequest( message_identifier=random.randint(0, UINT64_MAX), payment_identifier=1, secrethash=UNIT_SECRETHASH, amount=1, expiration=10, ) message.sign(LocalSigner(HOP1_KEY)) data = message.encode() if convert_to_hex: data = '0x' + data.hex() else: data = json.dumps(message.to_dict()) else: data = overwrite_data event = dict( type='m.room.message', sender=USERID1, content={ 'msgtype': 'm.text', 'body': data, }, ) return room, event
def room_with_members(mock_raiden_service, partner_config_for_room): number_of_partners = partner_config_for_room["number_of_partners"] users_per_address = partner_config_for_room["users_per_address"] number_of_base_users = partner_config_for_room["number_of_base_users"] room_members: List[User] = list() base_users = create_new_users_for_address(mock_raiden_service.signer, number_of_base_users) room_members.extend(base_users) for _ in range(number_of_partners): users = create_new_users_for_address(number_of_users=users_per_address) room_members.extend(users) room_id = "!roomofdoom:server" room = Room(client=None, room_id=room_id) # type: ignore for member in room_members: room._mkmembers(member) return room, number_of_partners > 1
def make_message_text(sign=True, overwrite_data=None): room = Room(None, "!roomID:server") # type: ignore if not overwrite_data: data = MessageSerializer.serialize(make_message(sign=sign)) else: data = overwrite_data event = dict( type="m.room.message", sender=USERID1, content={"msgtype": "m.text", "body": data} ) return room, event
def make_message(sign=True, overwrite_data=None): room = Room(None, "!roomID:server") if not overwrite_data: message = SecretRequest( message_identifier=random.randint(0, UINT64_MAX), payment_identifier=1, secrethash=factories.UNIT_SECRETHASH, amount=1, expiration=10, signature=EMPTY_SIGNATURE, ) if sign: message.sign(LocalSigner(factories.HOP1_KEY)) data = MessageSerializer.serialize(message) else: data = overwrite_data event = dict( type="m.room.message", sender=USERID1, content={"msgtype": "m.text", "body": data} ) return room, event
@pytest.fixture def create_sync_filter_patch(monkeypatch, sync_filter_dict): def mock_create_sync_filter(self, user_id, sync_filter): # pylint: disable=unused-argument count = len(sync_filter_dict) sync_filter_dict[count] = sync_filter return {"filter_id": count} monkeypatch.setattr(GMatrixHttpApi, "create_filter", mock_create_sync_filter) @pytest.mark.parametrize( "filter_params", [ { "not_rooms": [ Room(None, "!room1:server"), # type: ignore Room(None, "!room2:server"), # type: ignore ], "rooms": [Room(None, "!room1:server")], # type: ignore "limit": None, }, {"not_rooms": None, "rooms": None, "limit": 0}, { "not_rooms": [ Room(None, "!room1:server"), # type: ignore Room(None, "!room2:server"), # type: ignore ], "rooms": None, "limit": 10, }, {"not_rooms": None, "rooms": None, "limit": None},
def create_sync_filter_patch(monkeypatch, sync_filter_dict): def mock_create_sync_filter(self, user_id, sync_filter): # pylint: disable=unused-argument count = len(sync_filter_dict) sync_filter_dict[count] = sync_filter return {"filter_id": count} monkeypatch.setattr(GMatrixHttpApi, "create_filter", mock_create_sync_filter) @pytest.mark.parametrize( "filter_params", [ { "not_rooms": [ Room(None, "!room1:server"), # type: ignore Room(None, "!room2:server"), # type: ignore ], "rooms": [ Room(None, "!room1:server") # type: ignore ], "limit": None, }, { "not_rooms": None, "rooms": None, "limit": 0 }, { "not_rooms": [