883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
117 lines
5.9 KiB
Lua
117 lines
5.9 KiB
Lua
-- Pure original-API probe fixtures. No actual game/input/network/state changes.
|
|
local originalPrint = print
|
|
local output, secrets, calls, frames = {}, {}, {}, 0
|
|
print = function(...) output[#output + 1] = {...} end
|
|
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 function api(name, info, description)
|
|
return {
|
|
GetSpellName = function(id) calls[#calls + 1] = {'name', id}; return name end,
|
|
GetSpellInfo = function(id) calls[#calls + 1] = {'info', id}; return info end,
|
|
GetSpellDescription = function(id) calls[#calls + 1] = {'description', id}; return description end,
|
|
}
|
|
end
|
|
local function info(id)
|
|
return {name = 'Diplomacy', spellID = id, iconID = 134328, castTime = 0,
|
|
minRange = 0, maxRange = 0, arbitrary = 'DO_NOT_EXPORT'}
|
|
end
|
|
C_Spell = api('Diplomacy', info(20599), 'Reputation gains increased by 10%.')
|
|
local originalAPI = C_Spell
|
|
dofile(arg[1] .. '/client_addons/GatewayDiagnostics/GatewayDiagnostics.lua')
|
|
local slash = SlashCmdList.GATEWAYDIAGNOSTICS
|
|
slash('spell-info 20599')
|
|
local definitions = GatewayDiagnosticsSaved.spellDefinitions
|
|
local row = definitions[20599]
|
|
assert(row.nameStatus == 'ok' and row.infoStatus == 'ok' and row.descriptionStatus == 'ok')
|
|
assert(row.name == 'Diplomacy' and row.spellID == 20599 and row.iconID == 134328)
|
|
assert(row.castTime == 0 and row.minRange == 0 and row.maxRange == 0)
|
|
assert(row.description == 'Reputation gains increased by 10%.' and row.arbitrary == nil)
|
|
assert(C_Spell == originalAPI and GatewayDiagnosticsSaved.unrelated.retained)
|
|
assert(GatewayDiagnosticsSaved.nativeSkillAcceptance.untouched)
|
|
local beforeCalls = #calls
|
|
for _, command in ipairs({'spell-info', 'spell-info 0', 'spell-info -1', 'spell-info 1.5',
|
|
'spell-info 2147483648', 'spell-info 1 extra', 'spell-info x', 'spell-info 1e2'}) do
|
|
slash(command)
|
|
assert(#calls == beforeCalls and definitions[20599] == row)
|
|
end
|
|
local hidden = setmetatable({}, {__index = function() error('Secret result indexed') end,
|
|
__tostring = function() error('Secret result stringified') end})
|
|
local secret = 'PRIVATE_SECRET_SENTINEL'
|
|
secrets[hidden], secrets[secret] = true, true
|
|
slash(secret)
|
|
assert(#calls == beforeCalls)
|
|
local cases = {
|
|
{api = nil, status = 'unsupported'},
|
|
{api = {}, status = 'unsupported'},
|
|
{api = api(nil, nil, nil), status = 'nil'},
|
|
{api = api(secret, hidden, secret), status = 'not-public'},
|
|
{api = setmetatable({}, {__index = function() error(secret) end}), status = 'failed'},
|
|
{api = {
|
|
GetSpellName = function() error(secret) end,
|
|
GetSpellInfo = function() error(secret) end,
|
|
GetSpellDescription = function() error(secret) end,
|
|
}, status = 'failed'},
|
|
}
|
|
for _, case in ipairs(cases) do
|
|
C_Spell = case.api
|
|
slash('spell-info 20599')
|
|
row = definitions[20599]
|
|
assert(row.nameStatus == case.status and row.infoStatus == case.status and row.descriptionStatus == case.status)
|
|
assert(row.name == nil and row.spellID == nil and row.iconID == nil and row.description == nil)
|
|
end
|
|
for _, value in ipairs({secret, hidden, math.huge, 0/0, -1, true, '134328'}) do
|
|
local bad = info(20599); bad.iconID = value
|
|
C_Spell = api('Diplomacy', bad, 'Public description')
|
|
slash('spell-info 20599'); row = definitions[20599]
|
|
assert(row.infoStatus == 'not-public' and row.iconID == nil and row.spellID == nil)
|
|
assert(row.name == 'Diplomacy' and row.description == 'Public description')
|
|
end
|
|
C_Spell = api('Diplomacy', setmetatable({}, {__index = function() error(secret) end}), 'Public description')
|
|
slash('spell-info 20599'); assert(definitions[20599].infoStatus == 'not-public')
|
|
C_Spell = api('Diplomacy', info(20598), 'Public description')
|
|
slash('spell-info 20599'); assert(definitions[20599].infoStatus == 'identity-mismatch')
|
|
local bad = info(20599); bad.name = 'Unrelated spell'
|
|
C_Spell = api('Diplomacy', bad, 'Public description')
|
|
slash('spell-info 20599'); assert(definitions[20599].infoStatus == 'identity-mismatch')
|
|
bad = info(20599); bad.minRange, bad.maxRange = 10, 5
|
|
C_Spell = api('Diplomacy', bad, 'Public description')
|
|
slash('spell-info 20599'); assert(definitions[20599].infoStatus == 'not-public')
|
|
C_Spell = api(string.rep('a', 257), info(20599), string.rep('b', 4097))
|
|
slash('spell-info 20599'); row = definitions[20599]
|
|
assert(row.nameStatus == 'not-public' and row.descriptionStatus == 'not-public' and row.description == nil)
|
|
-- At most sixteen IDs; updating an existing result is allowed at capacity.
|
|
GatewayDiagnosticsSaved.spellDefinitions = {}
|
|
C_Spell = {}
|
|
for id = 1, 16 do slash('spell-info ' .. id) end
|
|
definitions = GatewayDiagnosticsSaved.spellDefinitions
|
|
local count = 0
|
|
for _ in pairs(definitions) do count = count + 1 end
|
|
assert(count == 16)
|
|
beforeCalls = #calls
|
|
slash('spell-info 17'); assert(definitions[17] == nil and #calls == beforeCalls)
|
|
C_Spell = api('Diplomacy', info(1), 'Updated')
|
|
slash('spell-info 1'); assert(definitions[1].description == 'Updated')
|
|
local allowed = {nameStatus = true, infoStatus = true, descriptionStatus = true,
|
|
name = true, spellID = true, iconID = true, castTime = true,
|
|
minRange = true, maxRange = true, description = true}
|
|
for _, value in pairs(definitions) do
|
|
for key in pairs(value) do assert(allowed[key]) end
|
|
end
|
|
for _, line in ipairs(output) do
|
|
for _, value in ipairs(line) do
|
|
assert(type(value) == 'string' or type(value) == 'number')
|
|
if type(value) == 'string' then
|
|
assert(not value:find(secret, 1, true) and not value:find('DO_NOT_EXPORT', 1, true))
|
|
end
|
|
end
|
|
end
|
|
assert(frames == 1)
|
|
assert(GatewayDiagnosticsSaved.nativeSkillAcceptance.untouched)
|
|
print = originalPrint
|
|
print('Spell-info probe: original APIs, public allowlist, redacted failures, nil/unavailable distinction and sixteen-ID bound passed.')
|