Files
WoW-Hybrid-gateway/tests/native_mirror_timer_test.cpp
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

32 lines
2.1 KiB
C++

#include "world_translation.hpp"
#include "gateway/mirror_timer.hpp"
#include <iostream>
using namespace gateway;
static void check(bool ok,const char* why){if(!ok)throw Error(why);}
int main(){try{
NativeWorldTranslation world{};world.selected.guid=4520;world.realm=70;
unsigned emitted=0;
auto receive=[&](uint32_t op,const Bytes& input){
auto expected=forever_mirror_timer(op,input);
auto bundle=world.translate({op,input},0x46010046,0,nullptr);Reader r(bundle);
check(r.le(4)==1 && r.le(4)==expected.opcode,"source timer not routed exactly once");
check(r.take(r.le(4))==expected.body,"source timer payload changed in world dispatch");r.end();++emitted;
check(world.requests.empty() && !world.source_ghost && !world.source_health,"timer manufactured gameplay/state");
};
for(uint32_t timer=0;timer<3;++timer){
auto start=[&](uint32_t value,int32_t scale,bool paused){Bytes b;le(b,timer,4);le(b,value,4);le(b,60000,4);le(b,uint32_t(scale),4);le(b,paused,1);le(b,timer==2?5384:0,4);return b;};
receive(0x1d9,start(60000,-1,false)); // Enter water/dark water or real feign death.
receive(0x1d9,start(45123,-1,false)); // Source full status resend, never local ticking.
receive(0x1d9,start(45123,-1,true)); // Source freeze update.
Bytes b;le(b,timer,4);auto pause=b;pause.push_back(1);receive(0x1da,pause);
pause.back()=0;receive(0x1da,pause);receive(0x1d9,start(45333,10,false)); // Surface/refill.
receive(0x1db,b);receive(0x1db,b); // Genuine repeated stop remains idempotent client input.
}
auto before=world.requests.size();
bool rejected=false;
try{world.translate({0x1d9,Bytes{1,0,0,0}},0x46010046,0,nullptr);}catch(const Error&){rejected=true;}
check(rejected,"truncated source start accepted");
check(world.requests.size()==before,"malformed timer generated source request");
std::cout<<emitted<<" genuine source timer lifecycle packets route once through native world translator; no codec, local ticks or gameplay requests.\n";
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}