44 US cities (every missing state capital and DC) and 12 Canadian ones (every provincial and territorial capital), sized by metro population, with exchanges only where PeeringDB lists a real one. Level Tree is in every state capital; Cogentle, AT&Tease and Drizzle Electric in the bigger ones, and Drizzle on the Edmonton, Winnipeg, Saskatoon and Quebec City exchanges as Hurricane is. Greenland: Nuuk, Qaqortoq, Sisimiut and Aasiaat, each its own landmass (no road or fiber over the ice), on Greenland Connect's real landings (Iceland-Qaqortoq- Nuuk-Newfoundland) and Connect-the-Dots North up the coast. Too Sassy (Tusass, AS8818) is the one operator. Iqaluit has only satellites: a beach, no seller. New regional carriers: Bell Alien (Bell Aliant, AS855), SaskTell-Tale (SaskTel, AS803), Northwest Passage Tel (Northwestel, AS22573). Victoria and Iqaluit are documented W3 exceptions, Greenland a W2 one; the real names go on the blocklist.
35 lines
2.3 KiB
JavaScript
35 lines
2.3 KiB
JavaScript
// A few seeded random games (scripts/lib/route-fuzz.js), played move for move on main's page and on this checkout's:
|
|
// after every move and day both route identically and keep the same game state, and this checkout routes the same with
|
|
// the routing cache (RC) on and off. scripts/route-fuzz.js plays hundreds of these; here a handful, so CI stays quick.
|
|
// Without git's origin/main (a bare tarball), the base is this checkout's own page: the cache on/off check still runs.
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
const page = require('../scripts/lib/page');
|
|
const { openPage, playGame } = require('../scripts/lib/route-fuzz');
|
|
|
|
function pages() {
|
|
const head = path.join(os.tmpdir(), `tubes-fuzz-test-${process.pid}-head.html`);
|
|
fs.writeFileSync(head, page.assemble().html);
|
|
let base = head;
|
|
try { const b = path.join(os.tmpdir(), `tubes-fuzz-test-${process.pid}-base.html`); fs.writeFileSync(b, page.assembleRef('origin/main')); base = b; } catch (e) {}
|
|
let P = { base: openPage(base, 'base'), head: openPage(head, 'head') };
|
|
// A change to the world itself (cities, networks, cables) cannot route like main: there is no same game to compare.
|
|
// Then the base is this checkout too, and the cache on/off check still runs; equivalence with main resumes once it lands.
|
|
const world = (p) => p.ev("JSON.stringify([CITIES.map(c=>[c.id,c.land,c.P]),NETS.map(n=>[n.id,n.pops,n.ix,n.share,n.price,n.up]),CABLES.map(c=>[c.id,c.pairs.map(q=>[q[0],q[1]])])])");
|
|
if (base !== head && world(P.base) !== world(P.head)) { console.log('# route fuzz: the world differs from main, so both pages are this checkout'); P = { base: openPage(head, 'base'), head: P.head }; }
|
|
return P;
|
|
}
|
|
|
|
test('random games route the same as main, with and without the routing cache, move for move', () => {
|
|
const P = pages();
|
|
// Seeds that start a normal game, a sandbox, a scenario and a puzzle, with transit, exchanges, PNIs and RouteScript.
|
|
for (const seed of [20, 23, 27, 26]) {
|
|
const g = playGame(P, seed, { moves: 35 });
|
|
assert.equal(g.div, null, `seed ${seed} diverged: ${JSON.stringify(g.div, null, 1)}`);
|
|
assert.ok(g.moves >= 35, `seed ${seed} played its moves`);
|
|
assert.deepEqual(g.errors, [], `seed ${seed}: no page errors`);
|
|
}
|
|
});
|