Files
WoW-Hybrid-gateway/tests/native_guild_rank_assignment_test.cpp
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

20 lines
2.2 KiB
C++

#include "gateway/guild_rank_assignment.hpp"
#include <iostream>
using namespace gateway;
void check(bool x,const char* m){if(!x)throw Error(m);}
int main(){try{
GuildInfo info{};info.id=21;info.name="HybridLocalTest";GuildRoster roster;roster.source_rank_rights={0xffffffff,0,0,0,0};
GuildRosterMember master;master.guid=4509;master.name="Gatewaytest";master.rank=0;GuildRosterMember peer;peer.guid=4513;peer.name="Chatpeer";peer.rank=4;roster.members={master,peer};
auto request=[&](uint64_t who,uint32_t rank){auto b=pack_guid(forever_player_guid(who,70));le(b,rank,4);return b;};
auto [plan,first]=GuildRankAssignment::prepare(request(4513,1),info,roster,4509,70,0);check(first.opcode==0x8b&&plan.expected_rank==3,"initial promote");
check(!plan.observe(info,roster,0),"stale roster replayed mutation");check(!plan.complete&&!plan.conflicted,"stale roster completed intent");
roster.members[1].rank=3;auto second=plan.observe(info,roster,0);check(second&&second->opcode==0x8b&&plan.expected_rank==2,"confirmed next promote");
check(!plan.observe(info,roster,0),"same real roster replayed mutation");
roster.members[1].rank=2;check(plan.observe(info,roster,0).has_value(),"third bounded step missing");
roster.members[1].rank=1;check(!plan.observe(info,roster,0)&&plan.complete,"target not confirmed");
auto [down,demote]=GuildRankAssignment::prepare(request(4513,4),info,roster,4509,70,0);check(demote.opcode==0x8c,"demotion direction");roster.members[1].rank=3;check(!down.observe(info,roster,0)&&down.conflicted,"external rank change continued stale plan");
for(auto [who,rank]:{std::pair<uint64_t,uint32_t>{4513,0},{4509,1},{4514,1},{4513,10}}){bool rejected=false;try{GuildRankAssignment::prepare(request(who,rank),info,roster,4509,70,0);}catch(const Error&){rejected=true;}check(rejected,"unsafe target accepted");}
roster.source_rank_rights[0]=0;bool rejected=false;try{GuildRankAssignment::prepare(request(4513,2),info,roster,4509,70,0);}catch(const Error&){rejected=true;}check(rejected,"missing permission accepted");
std::cout<<"PASS Source-confirmed multi-rank sequencing, stale-roster no replay, conflict stop, hierarchy/member/permission guards\n";
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}