883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
76 lines
3.7 KiB
Python
76 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Public native actor snapshot ABI fixture, including genuine source peer type4.
|
|
|
|
The shape is exported by NativeEntityTranslation::snapshot via
|
|
GW_WIRE_ENTITY_STATE / gw_wire_entity_data. These are synthetic ABI fixtures,
|
|
not a live capture or gameplay acceptance claim.
|
|
"""
|
|
import importlib
|
|
import struct
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
import engine_pipe_host as pipe
|
|
|
|
class NativePeerMetadata(unittest.TestCase):
|
|
guid=0x1020304050607080
|
|
native=bytes.fromhex('112233445566778899aabbccddeeff00')
|
|
|
|
def header(self,abi=3,count=1,offset=0):
|
|
size={1:10288,2:41008,3:43088}[abi]
|
|
return struct.pack('<12I',abi,size,0,0,0,0,0,0,0,0,count,0)
|
|
|
|
def row(self,kind=4,sent=1,entry=0,creature_type=0):
|
|
return struct.pack('<Q16s4I',self.guid,self.native,entry,kind,sent,creature_type)
|
|
|
|
def test_source_export_kind4_contract_decodes_in_all_supported_snapshot_abis(self):
|
|
for abi in (1,2,3):
|
|
with self.subTest(abi=abi):
|
|
r=pipe.decode_entity_page(self.header(abi),self.row())
|
|
self.assertEqual(r['actors'],[dict(legacy_guid=str(self.guid),modern_guid=self.native.hex(),
|
|
entry=0,kind=4,sent=True,creature_type=0)])
|
|
|
|
def test_unsent_peer_is_not_falsely_marked_visible(self):
|
|
r=pipe.decode_entity_page(self.header(),self.row(sent=0))
|
|
self.assertFalse(r['actors'][0]['sent'])
|
|
|
|
def test_native_player_type6_is_not_a_source_actor_kind(self):
|
|
for kind in (0,1,2,6,8,255):
|
|
with self.subTest(kind=kind),self.assertRaises(ValueError):
|
|
pipe.decode_entity_page(self.header(),self.row(kind=kind))
|
|
|
|
def test_peer_cannot_borrow_creature_template_or_creature_type(self):
|
|
for fields in [dict(entry=1),dict(creature_type=1),dict(entry=123,creature_type=7)]:
|
|
with self.subTest(fields=fields),self.assertRaises(ValueError):
|
|
pipe.decode_entity_page(self.header(),self.row(**fields))
|
|
|
|
def test_boolean_and_creature_metadata_bounds_remain_strict(self):
|
|
for fields in [dict(sent=2),dict(kind=3,entry=123,creature_type=16)]:
|
|
with self.subTest(fields=fields),self.assertRaises(ValueError):
|
|
pipe.decode_entity_page(self.header(),self.row(**fields))
|
|
|
|
def test_existing_creature_gameobject_and_corpse_kinds_remain_supported(self):
|
|
for kind in (3,5,7):
|
|
with self.subTest(kind=kind):
|
|
r=pipe.decode_entity_page(self.header(),self.row(kind=kind,entry=123,creature_type=7 if kind==3 else 0))
|
|
self.assertEqual(r['actors'][0]['kind'],kind)
|
|
|
|
def test_actor_fixture_exports_public_identity_scalars_only(self):
|
|
actor=pipe.decode_entity_page(self.header(),self.row())['actors'][0]
|
|
self.assertEqual(set(actor),{'legacy_guid','modern_guid','entry','kind','sent','creature_type'})
|
|
self.assertNotIn('ActivePlayer',actor);self.assertNotIn('account',actor)
|
|
self.assertNotIn('inventory',actor);self.assertNotIn('owner',actor)
|
|
|
|
def test_existing_page_body_bounds_are_not_relaxed(self):
|
|
for body in [self.row()[:-1],self.row()+b'\x00']:
|
|
with self.subTest(bytes=len(body)),self.assertRaises(ValueError):
|
|
pipe.decode_entity_page(self.header(),body)
|
|
with self.assertRaises(ValueError):pipe.decode_entity_page(self.header(),self.row(),offset=1)
|
|
|
|
def test_existing_owner_reload_uses_current_decoder_without_host_restart(self):
|
|
reloaded=importlib.reload(pipe)
|
|
self.assertEqual(reloaded.decode_entity_page(self.header(),self.row())['actors'][0]['kind'],4)
|
|
|
|
if __name__=='__main__':unittest.main()
|