test_server: improve coverage

This commit is contained in:
Brian Warner 2016-12-23 13:41:00 -05:00
parent b8313b4595
commit db968900d9

View File

@ -1334,7 +1334,7 @@ class Transit(ServerBase, unittest.TestCase):
a1.transport.loseConnection()
@defer.inlineCallbacks
def test_impatience(self):
def test_impatience_old(self):
ep = clientFromString(reactor, self.transit)
a1 = yield connectProtocol(ep, Accumulator())
@ -1347,3 +1347,20 @@ class Transit(ServerBase, unittest.TestCase):
self.assertEqual(a1.data, exp)
a1.transport.loseConnection()
@defer.inlineCallbacks
def test_impatience_new(self):
ep = clientFromString(reactor, self.transit)
a1 = yield connectProtocol(ep, Accumulator())
token1 = b"\x00"*32
side1 = b"\x01"*8
# sending too many bytes is impatience.
a1.transport.write(b"please relay " + hexlify(token1) +
b" for side " + hexlify(side1) + b"\nNOWNOWNOW")
exp = b"impatient\n"
yield a1.waitForBytes(len(exp))
self.assertEqual(a1.data, exp)
a1.transport.loseConnection()