Files
WoW-Hybrid-gateway/tests/gateway_aura_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

105 lines
6.7 KiB
Lua

-- Pure original-API diagnostics; never starts a client or sends a packet.
local originalPrint, output, secrets, calls = print, {}, {}, {}
print = function(...) output[#output + 1] = {...} end
local frames = 0
CreateFrame = function()
frames = frames + 1
return {RegisterEvent = function() end, SetScript = function() end}
end
SlashCmdList = {}
issecretvalue = function(value) return secrets[value] or false end
GatewayDiagnosticsSaved = {unrelated = {retained = true}, nativeSkillAcceptance = {untouched = true}}
local melee, spell, cooldown, aura = 20.5, 4.25, {startTime = 0, duration = 0, isEnabled = true}, nil
GetCritChance = function(...) assert(select('#', ...) == 0); calls[#calls + 1] = 'melee'; return melee end
GetSpellCritChance = function(...) assert(select('#', ...) == 0); calls[#calls + 1] = 'spell'; return spell end
C_Spell = {GetSpellCooldown = function(id) assert(id == 20600); calls[#calls + 1] = 'cooldown'; return cooldown end}
C_UnitAuras = {GetPlayerAuraBySpellID = function(id) assert(id == 20600); calls[#calls + 1] = 'aura'; return aura end}
local originalCrit, originalSpellAPI, originalAuraAPI = GetCritChance, C_Spell, C_UnitAuras
dofile(arg[1] .. '/client_addons/GatewayDiagnostics/GatewayDiagnostics.lua')
local slash = SlashCmdList.GATEWAYDIAGNOSTICS
slash('aura-test 20600 deadbeef before')
local context = GatewayDiagnosticsSaved.nativeAuraAcceptance
local row = context.samples[1]
assert(context.run == 'deadbeef' and context.spell == 20600 and #context.samples == 1)
assert(row.phase == 'before' and row.meleeCrit == 20.5 and row.spellCrit == 4.25)
assert(row.meleeCritStatus == 'ok' and row.spellCritStatus == 'ok' and row.cooldownStatus == 'ok' and row.auraStatus == 'nil')
assert(row.cooldown.duration == 0 and row.cooldown.isEnabled == true and row.aura == nil)
melee, spell = 22.5, 6.25
cooldown = {startTime = 100, duration = 180, isEnabled = true, private = 'DO_NOT_EXPORT'}
aura = {spellId = 20600, duration = 20, expirationTime = 120, applications = 0, private = 'DO_NOT_EXPORT'}
slash('aura-test 20600 deadbeef active')
melee, spell, aura = 20.5, 4.25, nil
slash('aura-test 20600 deadbeef expired')
assert(#context.samples == 3 and context.samples[2].meleeCrit - context.samples[1].meleeCrit == 2)
assert(context.samples[2].aura.duration == 20 and context.samples[2].aura.applications == 0)
assert(context.samples[2].aura.private == nil and context.samples[2].cooldown.private == nil)
assert(context.samples[3].auraStatus == 'nil' and context.samples[3].meleeCrit == context.samples[1].meleeCrit)
assert(GetCritChance == originalCrit and C_Spell == originalSpellAPI and C_UnitAuras == originalAuraAPI)
assert(GatewayDiagnosticsSaved.unrelated.retained and GatewayDiagnosticsSaved.nativeSkillAcceptance.untouched)
local beforeCalls = #calls
for _, command in ipairs({'aura-test', 'aura-test 0 deadbeef before', 'aura-test 2147483648 deadbeef before',
'aura-test 1.5 deadbeef before', 'aura-test 1e2 deadbeef before', 'aura-test 20600 DEADbeef before',
'aura-test 20600 deadbee before', 'aura-test 20600 deadbeeff before', 'aura-test 20600 deadbeef restored',
'aura-test 20600 deadbeef active extra', 'aura-test 20600 12345678 active', 'aura-test 20601 deadbeef expired'}) do
slash(command); assert(GatewayDiagnosticsSaved.nativeAuraAcceptance == context and #context.samples == 3)
end
assert(#calls == beforeCalls)
local secret = 'PRIVATE_SENTINEL'
local hidden = setmetatable({}, {__index = function() error('Hidden result indexed') end,
__tostring = function() error('Hidden result stringified') end})
secrets[secret], secrets[hidden] = true, true
slash(secret); assert(#calls == beforeCalls)
-- A new run resets only this bounded diagnostics record. API failures are
-- fixed statuses; no raw error, protected value or arbitrary table survives.
melee, spell, cooldown, aura = secret, hidden, hidden, hidden
slash('aura-test 20600 1234abcd before')
row = GatewayDiagnosticsSaved.nativeAuraAcceptance.samples[1]
assert(row.meleeCritStatus == 'not-public' and row.spellCritStatus == 'not-public')
assert(row.cooldownStatus == 'not-public' and row.auraStatus == 'not-public')
assert(row.meleeCrit == nil and row.spellCrit == nil and row.cooldown == nil and row.aura == nil)
for _, value in ipairs({math.huge, 0/0, -1, 1001, true, '20'}) do
melee, spell = value, value
slash('aura-test 20600 1234abcd before')
row = GatewayDiagnosticsSaved.nativeAuraAcceptance.samples[#GatewayDiagnosticsSaved.nativeAuraAcceptance.samples]
assert(row.meleeCritStatus == 'not-public' and row.spellCritStatus == 'not-public')
end
GetCritChance = function() error(secret) end
GetSpellCritChance = nil
C_Spell = setmetatable({}, {__index = function() error(secret) end})
C_UnitAuras = nil
slash('aura-test 20600 1234abcd before')
row = GatewayDiagnosticsSaved.nativeAuraAcceptance.samples[8]
assert(row.meleeCritStatus == 'failed' and row.spellCritStatus == 'unsupported')
assert(row.cooldownStatus == 'failed' and row.auraStatus == 'unsupported')
GetCritChance, GetSpellCritChance = function() return 0 end, function() return 0 end
cooldown = {startTime = 0, duration = 0, isEnabled = false}
aura = {spellId = 20598, duration = 20, expirationTime = 100, applications = 1}
C_Spell, C_UnitAuras = originalSpellAPI, originalAuraAPI
slash('aura-test 20600 feedbabe before')
row = GatewayDiagnosticsSaved.nativeAuraAcceptance.samples[1]
assert(row.meleeCrit == 0 and row.spellCrit == 0 and row.cooldown.isEnabled == false)
assert(row.auraStatus == 'identity-mismatch' and row.aura == nil)
for _, value in ipairs({secret, math.huge, 0/0, -1, 86401, true, '20'}) do
cooldown = {startTime = 0, duration = value, isEnabled = true}
aura = {spellId = 20600, duration = value, expirationTime = 120, applications = 1}
slash('aura-test 20600 feedbabe active')
row = GatewayDiagnosticsSaved.nativeAuraAcceptance.samples[#GatewayDiagnosticsSaved.nativeAuraAcceptance.samples]
assert(row.cooldownStatus == 'not-public' and row.auraStatus == 'not-public')
end
cooldown, aura = nil, nil
slash('aura-test 20600 00000000 before')
context = GatewayDiagnosticsSaved.nativeAuraAcceptance
for _ = 1, 11 do slash('aura-test 20600 00000000 active') end
assert(#context.samples == 12)
beforeCalls = #calls
slash('aura-test 20600 00000000 before'); slash('aura-test 20600 00000000 expired')
assert(#context.samples == 12 and #calls == beforeCalls)
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)
print = originalPrint
print('Aura probe: three phases, original zero-argument crit APIs, public cooldown/aura fields, nonce ownership, twelve-sample bound and redacted failures passed; no gameplay actions.')