883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
39 lines
2.6 KiB
C++
39 lines
2.6 KiB
C++
#pragma once
|
|
// Public C ABI on a genuinely authenticated independent loopback fixture only.
|
|
// No direct access to transport internals, keys or production server state.
|
|
#include "session.h"
|
|
#include "gateway/world.hpp"
|
|
#include <algorithm>
|
|
#include <array>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
static gateway::Bytes exercise_movement_rejection(gw_native_transport* transport){
|
|
auto require=[](bool good,const char* why){
|
|
if(!good)throw std::runtime_error(std::string("movement rejection fixture: ")+why);
|
|
};
|
|
auto valid=gateway::forever_ground_movement(gateway::GroundMovement{42,1,100,{1,2,3,.5f}},70);
|
|
std::array<uint8_t,512> output{};uint32_t required=999;
|
|
auto unchanged=[&]{return std::all_of(output.begin(),output.end(),[](uint8_t b){return b==0xa5;});};
|
|
auto reject=[&](uint32_t opcode,std::span<const uint8_t> body){
|
|
output.fill(0xa5);required=999;
|
|
require(gw_native_transport_movement(transport,opcode,body.data(),uint32_t(body.size()),output.data(),uint32_t(output.size()),&required)==-1,"validation must reject nonfatally");
|
|
require(required==0 && unchanged(),"rejected movement wrote output");
|
|
require(gw_native_transport_authenticated(transport)==1,"validation damaged authentication");
|
|
};
|
|
// Every truncated prefix includes decoder failures, rather than only null
|
|
// argument guards. Wrong ownership/opcode also use the pure decoder gate.
|
|
for(size_t n=0;n<valid.size();++n)reject(0x420000,std::span(valid).first(n));
|
|
auto foreign=gateway::forever_ground_movement(gateway::GroundMovement{43,1,100,{1,2,3,.5f}},70);
|
|
reject(0x420000,foreign);reject(0x42ffff,valid);
|
|
auto trailing=valid;trailing.push_back(0);reject(0x420000,trailing);
|
|
required=999;
|
|
require(gw_native_transport_movement(transport,0x420000,valid.data(),uint32_t(valid.size()),nullptr,0,&required)==-3 && required==48,"sizing must retain active-mover plus movement");
|
|
output.fill(0xa5);required=999;
|
|
require(gw_native_transport_movement(transport,0x420000,valid.data(),uint32_t(valid.size()),output.data(),47,&required)==-3 && required==48 && unchanged(),"short capacity changed output or prepared batch");
|
|
gateway::Bytes wire(required);uint32_t written=999;
|
|
require(!gw_native_transport_movement(transport,0x420000,valid.data(),uint32_t(valid.size()),wire.data(),uint32_t(wire.size()),&written) && written==48,"valid movement did not recover");
|
|
require(gw_native_transport_authenticated(transport)==1,"valid movement damaged authentication");
|
|
return wire; // Python peer independently decrypts both headers and payloads.
|
|
}
|