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

45 lines
2.8 KiB
Lua

-- Read-only original C_Container diagnostics; fake APIs never prove gameplay.
local realprint=print;local output={};print=function(...)output[#output+1]={...}end
CreateFrame=function()return {RegisterEvent=function()end,SetScript=function()end}end
SlashCmdList={};GatewayDiagnosticsSaved={unrelated=true}
local secrets={};issecretvalue=function(v)return secrets[v]or false end
local calls=0
C_Container={GetContainerNumSlots=function(b)calls=calls+1;return b==0 and 16 or 36 end,
GetContainerItemInfo=function(b,s)
calls=calls+1
if s==36 then return {itemID=1234,stackCount=20,isLocked=false,iconFileID=5678,hyperlink='DO_NOT_EXPORT'}end
end}
dofile(arg[1]..'/client_addons/GatewayDiagnostics/GatewayDiagnostics.lua')
local slash=SlashCmdList.GATEWAYDIAGNOSTICS
slash('bag-test deadbeef')
local result=GatewayDiagnosticsSaved.nativeBagAcceptance
assert(result.run=='deadbeef'and #result.bags==5 and GatewayDiagnosticsSaved.unrelated)
assert(#result.bags[1].slots==16 and result.bags[1].slots[1].status=='empty')
for b=2,5 do
local bag=result.bags[b];local last=bag.slots[36]
assert(bag.bag==b-1 and bag.numSlots==36 and #bag.slots==36)
assert(last.status=='ok'and last.itemID==1234 and last.count==20 and last.icon==5678 and not last.locked)
assert(last.hyperlink==nil)
end
slash('bank-test cafe1234')
local bank=GatewayDiagnosticsSaved.nativeBankAcceptance
assert(bank.run=='cafe1234'and #bank.bags==7 and bank.bags[1].bag==6)
for i=2,7 do assert(bank.bags[i].bag==i+5 and bank.bags[i].numSlots==36)end
assert(GatewayDiagnosticsSaved.nativeBagAcceptance==result)
local baseline=calls
for _,bad in ipairs({'bag-test','bag-test deadbee','bag-test deadbeeff','bag-test DEADBEEF','bag-test deadbeef extra'})do
slash(bad);assert(calls==baseline and GatewayDiagnosticsSaved.nativeBagAcceptance==result)
end
local hidden=setmetatable({},{__index=function()error('secret indexed')end});secrets[hidden]=true
C_Container.GetContainerItemInfo=function()return hidden end
slash('bag-test 12345678');assert(GatewayDiagnosticsSaved.nativeBagAcceptance.bags[1].slots[1].status=='not-public')
C_Container.GetContainerItemInfo=function()return {itemID=0/0,stackCount=1,isLocked=false,iconFileID=2}end
slash('bag-test 12345678');assert(GatewayDiagnosticsSaved.nativeBagAcceptance.bags[1].slots[1].status=='not-public')
C_Container.GetContainerNumSlots=function()return 37 end
slash('bag-test 12345678');assert(GatewayDiagnosticsSaved.nativeBagAcceptance.bags[1].status=='not-public')
C_Container=nil
slash('bag-test 12345678');assert(GatewayDiagnosticsSaved.nativeBagAcceptance.bags[1].status=='failed')
for _,line in ipairs(output)do for _,v in ipairs(line)do assert(tostring(v)~='DO_NOT_EXPORT')end end
print=realprint
print('Bag probe: all four36-slot containers, final slots, bounded input, and secret/error redaction passed.')