def test_writeDeferredFires(messageTransport): t = messageTransport d = t.write('hi') fired = [] d.addCallback(fired.append) assert not fired runUntilNext(t._clock) t._parseMessage(t._now(), Message(0, 1, [halfOpen(0, 2)], None, 0, '').pack()) assert fired[0] == t._now()
def test_writeDeferredFires(messageTransport): t = messageTransport d = t.write('hi') fired = [] d.addCallback(fired.append) assert not fired runUntilNext(t._clock) t._parseMessage(t._now(), Message(0, 1, [halfOpen(0, 2)], None, 0, '').pack()) assert fired[0] == t._now()
def test_messagesSendToLastHostWithValidPackets(serverMessageTransport): t = serverMessageTransport t.datagramReceived(clientNullMessage(1), clientHostPort) t.write('hi') runUntilNext(t._clock) assert t.transport.written[0][1] == clientHostPort t.datagramReceived('hi', clientHostPort2) runUntilNext(t._clock) runUntilNext(t._clock) assert t.transport.written[1][1] == clientHostPort
def test_messagesSendToLastHostWithValidPackets(serverMessageTransport): t = serverMessageTransport t.datagramReceived(clientNullMessage(1), clientHostPort) t.write('hi') runUntilNext(t._clock) assert t.transport.written[0][1] == clientHostPort t.datagramReceived('hi', clientHostPort2) runUntilNext(t._clock) runUntilNext(t._clock) assert t.transport.written[1][1] == clientHostPort
def test_sendingData(messageTransport): t = messageTransport t.write('hi') runUntilNext(t._clock) assert t._sendMessage.captured[0] == Message(1, 0, [], None, 0, 'hi')
def test_ack(messageTransport): t = messageTransport t._parseMessage(t._now(), Message(1, 0, [], None, 0, 'hi').pack()) runUntilNext(t._clock) assert t._sendMessage.captured[0] == Message(0, 1, [halfOpen(0, 2)], None, 0, '')
def test_sendingData(messageTransport): t = messageTransport t.write('hi') runUntilNext(t._clock) assert t._sendMessage.captured[0] == Message(1, 0, [], None, 0, 'hi')
def test_ack(messageTransport): t = messageTransport t._parseMessage(t._now(), Message(1, 0, [], None, 0, 'hi').pack()) runUntilNext(t._clock) assert t._sendMessage.captured[0] == Message(0, 1, [halfOpen(0, 2)], None, 0, '')