async def on_message_received(self, message: dict) -> None: cmd, args = message.get('command'), message.get('args', []) if cmd == 'ProcessNatPacket': self.process_nat_packet(Address.from_string(args[0]), args[1]) elif cmd == 'InitiateTest': port = args[0] assert 1024 < port < 65535 asyncio.ensure_future(self.initiate_test(port)) elif cmd == 'RelayAddress': self.relay_address = Address(*args[0])
def test_address_from_string_with_scheme(): address = Address.from_string("http://localhost:4000") assert address == Address("http://localhost", 4000)
def test_address_from_string(): address = Address.from_string("localhost:4000") assert address == Address("localhost", 4000)