Files
WoW-Hybrid-gateway/tests/native_session_abi_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

20 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Exercise the C ABI's failure boundary without sockets, secrets or a game."""
import ctypes as c
import sys
class Config(c.Structure):
_fields_=[('abi',c.c_uint32),('auth_port',c.c_uint16),('world_port',c.c_uint16),('world_build',c.c_uint32),('username',c.c_char_p),('password_path',c.c_char_p),('version_hash_path',c.c_char_p),('addon_path',c.c_char_p)]
lib=c.CDLL(sys.argv[1]);lib.gw_native_open.argtypes=[c.POINTER(Config),c.POINTER(c.c_void_p)];lib.gw_native_open.restype=c.c_int
lib.gw_native_character_count.argtypes=[c.c_void_p];lib.gw_native_character_count.restype=c.c_uint32
lib.gw_native_character_at.argtypes=[c.c_void_p,c.c_uint32,c.c_void_p];lib.gw_native_enter.argtypes=[c.c_void_p,c.c_uint64,c.c_void_p];lib.gw_native_close.argtypes=[c.c_void_p]
out=c.c_void_p(123)
assert lib.gw_native_open(None,c.byref(out))==-1 and out.value is None
assert lib.gw_native_open(None,None)==-1
for config in (Config(),Config(99,3724,8090,5875,b'LOCAL',b'p',b'h',b'a'),Config(1,3724,8090,7272,b'LOCAL',b'p',b'h',b'a'),Config(1,3724,8090,5875,b'X'*33,b'p',b'h',b'a')):
out=c.c_void_p(123);assert lib.gw_native_open(c.byref(config),c.byref(out))==-1 and out.value is None
assert lib.gw_native_character_count(None)==0
assert lib.gw_native_character_at(None,0,None)==-1
assert lib.gw_native_enter(None,4509,None)==-1
lib.gw_native_close(None)
print('Native C ABI: version/parameter bounds, null-output cleanup and exception-free invalid-session handling passed.')