883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
19 lines
1.5 KiB
C++
19 lines
1.5 KiB
C++
#include "gateway/realms.hpp"
|
|
#include <bit>
|
|
#include <iostream>
|
|
using namespace gateway;
|
|
void check(bool v){if(!v)throw Error("realm regression");}
|
|
template<class F>void rejects(F f){try{f();}catch(const Error&){return;}throw Error("malformed realm accepted");}
|
|
int main(){
|
|
Bytes body;le(body,0,4);le(body,3,1);
|
|
for(unsigned i=0;i<3;++i){le(body,i==0?6:1,4);le(body,i==1?2:0,1);cstring(body,"Realm"+std::to_string(i));
|
|
cstring(body,i==2?"192.0.2.1:8090":"127.0.0.1:"+std::to_string(8090+i));le(body,std::bit_cast<uint32_t>(0.5f),4);append(body,Bytes{4,1,0});}
|
|
le(body,2,2);auto realms=turtle_realm_list(body);check(realms.size()==3 && realms[0].type==6 && realms[0].characters==4 && realms[0].wire_id==0 && realms[0].population==.5f);
|
|
check(local_realm_endpoint(realms[0]).port==8090);rejects([&]{local_realm_endpoint(realms[1]);});rejects([&]{local_realm_endpoint(realms[2]);});
|
|
for(size_t n=0;n<body.size();++n)rejects([&]{turtle_realm_list(std::span(body).first(n));});
|
|
auto bad=body;bad.push_back(0);rejects([&]{turtle_realm_list(bad);});bad=body;bad.back()=1;rejects([&]{turtle_realm_list(bad);});
|
|
auto r=realms[0];for(auto address:{"localhost:8090","127.0.0.1:0","127.0.0.1:65536","127.0.0.1:80evil","127.0.0.1:80:81","127.0.0.1:-1","127.0.0.1:"}){r.address=address;rejects([&]{local_realm_endpoint(r);});}
|
|
Bytes empty(5);le(empty,2,2);check(turtle_realm_list(empty).empty());
|
|
std::cout<<"Tortoise1.x multi-realm metadata, complete truncation matrix and loopback selection policy passed\n";
|
|
}
|