def test_protocol_header_server(): with pytest.raises( exceptions.VersionMismatchException, match=r"received incorrect version from server, got version=0x83 expected version=0x3", ): p = protocol.Protocol(server_role=True) p.version = 3 p._check_version(0x83)
def test_protocol_header_bad(): with pytest.raises( exceptions.VersionMismatchException, match=r"received incorrect version from server", ): p = protocol.Protocol() p.version = 2 stream = SBytes(b"\x83\x00\x00\x00\x00\x00\x00\x00\x01") p.decode_header(stream)
def test_protocol_baseclass_register_err(): with pytest.raises( exceptions.InternalDriverError, match=r"subclass should implement method" ): p = protocol.Protocol() p.register(1, 1)
def test_protocol_header_good(): p = protocol.Protocol() p.version = 3 stream = SBytes(b"\x83\x00\x00\x00\x00\x00\x00\x00\x01") data = p.decode_header(stream) assert data[4] == 1