367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
114 lines
6.8 KiB
Python
114 lines
6.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Actual local Forever logout/cancel and optional authenticated re-entry.
|
|
|
|
Uses original UI actions, genuine source responses and read-only server checks.
|
|
No credentials, GM commands, database writes or synthetic lifecycle packets.
|
|
Requires the designated disposable character as the sole local online character.
|
|
"""
|
|
import argparse
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import secrets
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
import client_ui as ui
|
|
from client_session import Session
|
|
from local_tortoise import db
|
|
from native_engine_character_test import Controller, ROOT, local_listeners
|
|
from native_test_guard import (require_authenticated_turtle_realm,
|
|
require_local_turtle_ports, require_native_gameplay_policy, require_solo_test_character)
|
|
from native_world_trace import WorldTrace
|
|
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--character',type=int,required=True)
|
|
parser.add_argument('--full-reentry',action='store_true')
|
|
parser.add_argument('--evidence',type=Path,required=True)
|
|
args=parser.parse_args();path=args.evidence.resolve()
|
|
if not 0<args.character<2**32 or not path.is_relative_to(ROOT/'runtime'):
|
|
parser.error('Require a real local character GUID and runtime evidence path')
|
|
os.umask(0o077);require_local_turtle_ports(local_listeners())
|
|
c=Controller(int((ROOT/'runtime/native-client.pid').read_text()))
|
|
require_authenticated_turtle_realm(c.rpc('inspect-wire-account'))
|
|
require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'))
|
|
require_solo_test_character(args.character,db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
|
|
report=dict(pid=c.pid,character=args.character,external_gateway_running=False,
|
|
full_reentry_requested=args.full_reentry,complete=False)
|
|
# The full test crosses an explicit character-selection generation boundary.
|
|
# Do not merge old/new object-field counters; retain continuous wire metadata.
|
|
trace=WorldTrace(c,collect_fields=False)
|
|
try:
|
|
with trace:
|
|
with Session(c.pid) as s:
|
|
s.wait_world(10);report['phase']='cancel';s.macro('/logout')
|
|
try:
|
|
report['root']=trace.wait(3,0x600029,3)
|
|
report['root_ack']=trace.wait(2,0x42002c,2)
|
|
finally:
|
|
# Use the ORIGINAL Cancel button. Calling CancelLogout()
|
|
# directly cancels server state but leaves the original
|
|
# countdown popup alive; its later dismissal can cancel a
|
|
# subsequent logout. This layout is actual-client verified.
|
|
g=s.win.get_geometry()
|
|
if g.width*9!=g.height*16:raise RuntimeError('Unverified logout-dialog aspect; preserve state')
|
|
s.focus();ui.click_at(s.d,s.win,round(1024*g.width/2048),round(174*g.height/1152))
|
|
report['cancel_ack']=trace.wait(3,0x470132,3)
|
|
report['unroot']=trace.wait(3,0x60002a,3)
|
|
report['unroot_ack']=trace.wait(2,0x42002d,2)
|
|
require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'))
|
|
report['cancel_verified']=True
|
|
s.shot(path.with_name(path.stem+'-cancel.png'))
|
|
if args.full_reentry:
|
|
report['phase']='logout';started=time.monotonic();anchor=trace.bookmark()
|
|
s.macro('/logout')
|
|
report['source_complete']=trace.wait(1,0x4d,30,after_index=anchor)
|
|
report['native_complete']=trace.wait(3,0x470131,3,after_index=anchor)
|
|
c.wait(lambda:s.state()=='characters',12)
|
|
report['logout_seconds']=round(time.monotonic()-started,3)
|
|
c.wait(lambda:db(f'SELECT online FROM tw_char.characters WHERE guid={args.character};')=='0',8)
|
|
report['saved_after_logout']=db(f'SELECT health,playerFlags,position_x,position_y,position_z FROM tw_char.characters WHERE guid={args.character};')
|
|
s.shot(path.with_name(path.stem+'-characters.png'))
|
|
# Release the UI lock before the existing world-entry controller.
|
|
if args.full_reentry:
|
|
report['phase']='reentry';entry=path.with_name(path.stem+'-reentry.json')
|
|
log=path.with_name(path.stem+'-reentry.log')
|
|
with log.open('w') as output:
|
|
result=subprocess.run([sys.executable,str(ROOT/'ops/native_world_entry_test.py'),
|
|
'--timeout','45','--enable-gameplay','--evidence',str(entry)],
|
|
stdout=output,stderr=subprocess.STDOUT,timeout=70)
|
|
report['reentry_exit']=result.returncode
|
|
if result.returncode:raise RuntimeError('Original re-entry readiness failed; inspect retained report, no retry sent')
|
|
r=json.loads(entry.read_text())
|
|
report['reentry_verified']=r['native_world_entry_verified'] and r['native_gameplay_policy'] is not None
|
|
require_authenticated_turtle_realm(c.rpc('inspect-wire-account'))
|
|
require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'))
|
|
name=db(f'SELECT name FROM tw_char.characters WHERE guid={args.character};')
|
|
if not name.isascii() or not name.isalpha() or not 1<=len(name)<=12:
|
|
raise RuntimeError('Unsupported original self-whisper name; no text sent')
|
|
with Session(c.pid) as s:
|
|
s.wait_world(10);anchor=trace.bookmark()
|
|
# Reuse the verified original public chat API. Modern /w
|
|
# input/window creation is a separate UI acceptance check.
|
|
s.macro('/run SendChatMessage("GW_REENTRY_'+secrets.token_hex(4)+'","WHISPER",nil,"'+name+'")')
|
|
report['self_whisper_request']=trace.wait(2,0x2d0008,3,after_index=anchor)
|
|
report['source_chat_reply']=trace.wait(1,0x96,3,after_index=anchor)
|
|
s.shot(path.with_name(path.stem+'-world.png'))
|
|
report['self_whisper_transport_verified']=True
|
|
report['phase']='complete';report['complete']=True
|
|
finally:
|
|
report.update(trace.report())
|
|
report['policy']=c.rpc('inspect-native-channel-policy')
|
|
pipe=c.rpc('inspect-engine-pipe',unit_fields_only=True)
|
|
report['pipe']={k:pipe[k]for k in('error','closed','world_auth','world','movement_failure')}
|
|
path.parent.mkdir(parents=True,exist_ok=True);path.write_text(json.dumps(report,indent=2)+'\n');path.chmod(0o600)
|
|
print(json.dumps({k:report.get(k)for k in('pid','complete','cancel_verified','logout_seconds',
|
|
'reentry_verified','self_whisper_transport_verified','lost_metadata_rows','observer_error')}))
|
|
return 0
|
|
|
|
|
|
if __name__=='__main__':raise SystemExit(main())
|