def test_accept(self, tco):
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.accept()
assert excinfo.value.errno == errno.EINVAL
tco.setsockopt(nfc.llcp.SO_RCVMIU, 1000)
tco.setsockopt(nfc.llcp.SO_RCVBUF, 2)
tco.listen(backlog=1)
assert tco.state.LISTEN is True
tco.enqueue(nfc.llcp.pdu.Connect(tco.addr, 17, 500, 15))
dlc = tco.accept()
assert isinstance(dlc, nfc.llcp.tco.DataLinkConnection)
assert dlc.state.ESTABLISHED is True
assert dlc.getsockopt(nfc.llcp.SO_RCVMIU) == 1000
assert dlc.getsockopt(nfc.llcp.SO_SNDMIU) == 500
assert dlc.getsockopt(nfc.llcp.SO_RCVBUF) == 2
assert tco.dequeue(128, 4) == \
nfc.llcp.pdu.ConnectionComplete(17, tco.addr, 1000, 2)
threading.Timer(0.01, tco.close).start()
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.accept()
assert excinfo.value.errno == errno.EPIPE
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.accept()
assert excinfo.value.errno == errno.ESHUTDOWN
评论列表
文章目录