Files
WoW-Hybrid-gateway/tests/gateway_skill_probe_test.lua
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

72 lines
4.7 KiB
Lua

-- Pure slash-handler diagnostics. No actual game, input, mutation or network.
local originalPrint=print
local output={};print=function(...)output[#output+1]={...}end
local apiCalls,frames=0,0
CreateFrame=function()
frames=frames+1
return {RegisterEvent=function()end,SetScript=function()end}
end
SlashCmdList={}
local secrets={}
issecretvalue=function(value)return secrets[value]or false end
GatewayDiagnosticsSaved={unrelated={retained=true}}
local info={rank=303,maxRank=303,modifier=0,password='DO_NOT_EXPORT'}
C_SkillInfo={GetSkillLineInfoByID=function(id)apiCalls=apiCalls+1;assert(id==43);return info end}
dofile(arg[1]..'/client_addons/GatewayDiagnostics/GatewayDiagnostics.lua')
local slash=SlashCmdList.GATEWAYDIAGNOSTICS
slash('skill-test 43 deadbeef before')
local context=GatewayDiagnosticsSaved.nativeSkillAcceptance
assert(context.run=='deadbeef'and context.skill==43 and #context.samples==1)
assert(context.samples[1].phase=='before'and context.samples[1].rank==303 and context.samples[1].maxRank==303 and context.samples[1].modifier==0)
assert(context.samples[1].password==nil and GatewayDiagnosticsSaved.unrelated.retained)
info={rank=302,maxRank=303,modifier=0};slash('skill-test 43 deadbeef changed')
info={rank=303,maxRank=303,modifier=0};slash('skill-test 43 deadbeef restored')
assert(#context.samples==3 and context.samples[2].phase=='changed'and context.samples[2].rank==302 and context.samples[3].phase=='restored')
local beforeCalls=apiCalls
for _,command in ipairs({'skill-test 0 deadbeef before','skill-test 65536 deadbeef before','skill-test 43 DEADbeef before',
'skill-test 43 deadbee before','skill-test 43 deadbeeff before','skill-test 43 deadbeef after',
'skill-test 43 deadbeef before extra','skill-test 1.5 deadbeef before','skill-test 43 deadbeef',
'skill-test 44 deadbeef changed','skill-test 43 12345678 restored'})do
slash(command);assert(GatewayDiagnosticsSaved.nativeSkillAcceptance==context and #context.samples==3)
end
assert(apiCalls==beforeCalls)
local secret='PRIVATE_CREDENTIAL_SENTINEL';secrets[secret]=true
slash(secret);slash(setmetatable({},{__tostring=function()error('Secret object stringified')end}))
assert(GatewayDiagnosticsSaved.nativeSkillAcceptance==context and #context.samples==3 and apiCalls==beforeCalls)
-- Unsupported APIs, exceptions and secret/missing/invalid values are recorded
-- as fixed error codes, without copying raw results or error text.
local cases={
{api=nil,error='unsupported-skill-api'},
{api={},error='unsupported-skill-api'},
{api={GetSkillLineInfoByID=function()error(secret)end},error='skill-api-call-failed'},
{api={GetSkillLineInfoByID=function()return nil end},error='skill-api-result-unavailable'},
}
local hidden=setmetatable({},{__index=function()error('Private result must not be indexed')end});secrets[hidden]=true
cases[#cases+1]={api={GetSkillLineInfoByID=function()return hidden end},error='skill-api-result-unavailable'}
for _,bad in ipairs({secret,math.huge,0/0,1.5,true,'303',2147483648,-1})do
local value=bad
cases[#cases+1]={api={GetSkillLineInfoByID=function()return {rank=value,maxRank=303,modifier=0}end},error='skill-api-fields-not-public-integers'}
end
cases[#cases+1]={api={GetSkillLineInfoByID=function()return {rank=303,maxRank=303}end},error='skill-api-fields-not-public-integers'}
cases[#cases+1]={api={GetSkillLineInfoByID=function()return setmetatable({},{__index=function()error(secret)end})end},error='skill-api-fields-not-public-integers'}
for _,case in ipairs(cases)do
C_SkillInfo=case.api;slash('skill-test 43 1234abcd before')
local sample=GatewayDiagnosticsSaved.nativeSkillAcceptance.samples[1]
assert(sample.status=='error'and sample.error==case.error and sample.rank==nil and sample.maxRank==nil and sample.modifier==nil)
end
-- Three phase names, twelve total samples: repeated changed polling is bounded.
C_SkillInfo={GetSkillLineInfoByID=function()return {rank=303,maxRank=303,modifier=-3}end}
slash('skill-test 65535 abcdef01 before')
context=GatewayDiagnosticsSaved.nativeSkillAcceptance
assert(context.samples[1].modifier==-3)
for _=1,11 do slash('skill-test 65535 abcdef01 changed')end
assert(#context.samples==12)
slash('skill-test 65535 abcdef01 restored');assert(#context.samples==12)
slash('skill-test 65535 00000000 changed');assert(GatewayDiagnosticsSaved.nativeSkillAcceptance==context and #context.samples==12)
for _,line in ipairs(output)do
for _,value in ipairs(line)do assert(type(value)=='string'and not value:find(secret,1,true)and not value:find('DO_NOT_EXPORT',1,true))end
end
assert(frames==1) -- Only the pre-existing diagnostics frame; no probe events.
print=originalPrint
print('Skill probe: three phases, public finite integers, nonce ownership, bounded samples and redacted errors passed; no game/network actions.')