Files
Viano-Core/tests/clientless/test_graph_probe_cache.py
T
Nico 0173a434f4 Improve AdventureBot recruitment, world presence and performance
Manage Arthoran as a persistent level-60 tank profile, add Worgen forms and mounts, enable PvP and recruit through native LFG with preparation actions and player invitations.

Reduce repeated route and flight-planning work, bound failed-travel retries and add runtime timing diagnostics. Include 86 passing tests and measurements with 110 online bots.
2026-10-29 01:36:35 +01:00

29 lines
1.4 KiB
Python

"""Static MMAP proof cache isolation, failure handling and bounded lifetime."""
from pathlib import Path
import subprocess,tempfile
root=Path(__file__).resolve().parents[2]
code=r'''
#include "ClientlessGraphProbeCache.h"
#include <cassert>
#include <limits>
int main(){
ClientlessGraphProbeCache c;auto key=c.MakeKey(0,1,1,2,3,4,5,6);
assert(!c.Find(key));c.Record(key,false,10,0,10);assert(!c.Find(key));
c.Record(key,true,10,2,10);assert(!c.Find(key));
c.Record(key,true,std::numeric_limits<float>::infinity(),0,10);assert(!c.Find(key));
c.Record(key,true,10,0,9);assert(c.Find(key)&&c.Find(key)->Length==10);
assert(!c.Find(c.MakeKey(1,1,1,2,3,4,5,6))); // map isolation
assert(!c.Find(c.MakeKey(0,2,1,2,3,4,5,6))); // instance isolation
assert(!c.Find(c.MakeKey(0,1,4,5,6,1,2,3))); // directed connection
assert(!c.Find(c.MakeKey(0,1,1.0000001f,2,3,4,5,6))); // exact coordinates
c.Clear();assert(!c.Find(key)&&c.Size()==0);
for(unsigned i=0;i<32769;++i)c.Record(c.MakeKey(i,1,1,2,3,4,5,6),true,10,0,9);
assert(c.Size()==1&&c.Find(c.MakeKey(32768,1,1,2,3,4,5,6)));
}
'''
with tempfile.TemporaryDirectory() as d:
p=Path(d);(p/'test.cpp').write_text(code)
subprocess.run(['c++','-std=c++17','-I'+str(root/'src/server/game/World'),str(p/'test.cpp'),'-o',str(p/'test')],check=True)
subprocess.run([str(p/'test')],check=True)
print('Graph probe cache: exact directed/map/instance keys, successful geometry only, invalidation and bounded storage passed')