Merge remote-tracking branch 'upstream/main' into own-carrier-egress
This commit is contained in:
commit
a469844f61
42 changed files with 757 additions and 42 deletions
29
tests/cable-labels.test.js
Normal file
29
tests/cable-labels.test.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
// Zoomed in, cable names sit on their cables. Where short cables crowd (the Philippine islands), a name that would
|
||||
// land on another is left out, unless the cable touches the selected city.
|
||||
const labels = (ev, sel) => JSON.parse(ev(`(()=>{ACT.start({});S.nextFail=1e9;S.nextEvent=1e9;UI.sel=${sel ? `{type:'city',id:'${sel}'}` : 'null'};
|
||||
cam.x=(CITY.mnl.x+CITY.dvo.x)/2;cam.y=(CITY.mnl.y+CITY.dvo.y)/2;cam.z=4.5;const out=[];
|
||||
ctx.fillText=(t,x,y)=>out.push({t,x,y,w:ctx.measureText(t).width});ctx.strokeText=()=>{};drawCables([0]);return JSON.stringify(out);})()`));
|
||||
|
||||
test('cable names never sit on top of each other', () => {
|
||||
const { ev, errors } = load();
|
||||
const L = labels(ev);
|
||||
assert.ok(L.length > 5, 'names are drawn');
|
||||
assert.ok(L.some(l => l.t === 'Pan de Sal Cable Network'), 'the domestic cables are named');
|
||||
const hit = (a, b) => Math.abs(a.x - b.x) < (a.w + b.w) / 2 + 6 && Math.abs(a.y - b.y) < 14;
|
||||
const clash = [];
|
||||
for (let i = 0; i < L.length; i++) for (let j = i + 1; j < L.length; j++) if (hit(L[i], L[j])) clash.push(`${L[i].t} / ${L[j].t}`);
|
||||
assert.deepEqual(clash, []);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("a selected city's cables are always named", () => {
|
||||
const { ev, errors } = load();
|
||||
const plain = labels(ev).map(l => l.t), sel = labels(ev, 'ceb').map(l => l.t);
|
||||
for (const n of ['Pan de Sal Cable Network', 'Philippines Long Distance Relationship', 'Diverge VisMin Express']) assert.ok(sel.includes(n), n);
|
||||
assert.ok(sel.length >= plain.length);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
75
tests/durations.json
Normal file
75
tests/durations.json
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
"tests/any-home-city.test.js": 12.0,
|
||||
"tests/architect.test.js": 20.1,
|
||||
"tests/automation.test.js": 13.8,
|
||||
"tests/backbone-core.test.js": 27.5,
|
||||
"tests/badges-variants.test.js": 20.2,
|
||||
"tests/build.test.js": 1.3,
|
||||
"tests/capacity-deals.test.js": 12.6,
|
||||
"tests/chaos-monkey.test.js": 30.3,
|
||||
"tests/city-size.test.js": 8.5,
|
||||
"tests/compute-idempotent.test.js": 10.4,
|
||||
"tests/ddos-floods.test.js": 22.8,
|
||||
"tests/ddos-model.test.js": 31.7,
|
||||
"tests/eyeballs.test.js": 13.0,
|
||||
"tests/fiber-broker.test.js": 9.7,
|
||||
"tests/find-city.test.js": 9.6,
|
||||
"tests/game.test.js": 42.8,
|
||||
"tests/gameplay-rules.test.js": 42.9,
|
||||
"tests/gangnam.test.js": 12.3,
|
||||
"tests/glowball-sakura-lager.test.js": 15.8,
|
||||
"tests/i18n.test.js": 59.9,
|
||||
"tests/islands-and-arctic.test.js": 13.7,
|
||||
"tests/issues.test.js": 103.0,
|
||||
"tests/language-picker.test.js": 12.5,
|
||||
"tests/latency.test.js": 11.1,
|
||||
"tests/levels.test.js": 16.3,
|
||||
"tests/link-metrics.test.js": 22.0,
|
||||
"tests/link-trial.test.js": 6.4,
|
||||
"tests/load-time.test.js": 102.7,
|
||||
"tests/metric-panel.test.js": 8.1,
|
||||
"tests/modes.test.js": 41.1,
|
||||
"tests/more-cables.test.js": 14.3,
|
||||
"tests/moscow-premium.test.js": 12.0,
|
||||
"tests/networks-list.test.js": 6.4,
|
||||
"tests/new-game-speed.test.js": 10.1,
|
||||
"tests/optic-counts.test.js": 9.7,
|
||||
"tests/own-asn.test.js": 7.9,
|
||||
"tests/pages.test.js": 12.4,
|
||||
"tests/peering-desk.test.js": 13.9,
|
||||
"tests/peering.test.js": 27.6,
|
||||
"tests/perf.test.js": 10.9,
|
||||
"tests/persist.test.js": 16.1,
|
||||
"tests/pni-all.test.js": 12.5,
|
||||
"tests/pni-global.test.js": 17.9,
|
||||
"tests/pni-list.test.js": 15.4,
|
||||
"tests/pnis-and-sold-out.test.js": 11.6,
|
||||
"tests/puzzle-monkey.test.js": 7.9,
|
||||
"tests/puzzles.test.js": 73.3,
|
||||
"tests/regions.test.js": 80.3,
|
||||
"tests/release-story.test.js": 2.8,
|
||||
"tests/report-link.test.js": 12.0,
|
||||
"tests/router-art.test.js": 7.8,
|
||||
"tests/routers-per-pop.test.js": 8.1,
|
||||
"tests/routing-reference.test.js": 11.6,
|
||||
"tests/rules-locked.test.js": 8.4,
|
||||
"tests/rules.test.js": 29.4,
|
||||
"tests/sales-trial.test.js": 33.3,
|
||||
"tests/save-size.test.js": 16.1,
|
||||
"tests/save-slots.test.js": 48.5,
|
||||
"tests/scenarios-playtest.test.js": 113.2,
|
||||
"tests/sea-routing.test.js": 42.6,
|
||||
"tests/services.test.js": 15.7,
|
||||
"tests/specialist.test.js": 14.3,
|
||||
"tests/speed.test.js": 144.6,
|
||||
"tests/standing-orders.test.js": 66.8,
|
||||
"tests/subsea-upgrade-timing.test.js": 13.5,
|
||||
"tests/supply.test.js": 11.0,
|
||||
"tests/tier1-cone.test.js": 19.8,
|
||||
"tests/useless-subsea-upgrades.test.js": 7.2,
|
||||
"tests/utilities-caches.test.js": 9.5,
|
||||
"tests/utilities.test.js": 15.6,
|
||||
"tests/weekly-architect.test.js": 28.7,
|
||||
"tests/weekly-puzzle.test.js": 145.0,
|
||||
"tests/weekly-scenario.test.js": 54.4
|
||||
}
|
||||
71
tests/find-city.test.js
Normal file
71
tests/find-city.test.js
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const start = "ACT.start({});S.nextFail=1e9;S.nextEvent=1e9";
|
||||
|
||||
test('find a city by its name, without accents, by country or by its exchange (#218)', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(start);
|
||||
const find = q => ev(`findCities(${JSON.stringify(q)}).join()`).split(',');
|
||||
assert.equal(find('amster')[0], 'ams', 'the start of a name');
|
||||
assert.equal(find('AMSTERDAM')[0], 'ams', 'any case');
|
||||
assert.equal(find('sao paulo')[0], 'sao', 'accents are optional');
|
||||
assert.equal(find('paulo')[0], 'sao', 'a word inside the name');
|
||||
assert.ok(find('germany').includes('fra'), 'the country in English');
|
||||
assert.ok(find('germany').includes('muc'));
|
||||
assert.ok(find('Brezn')[0] === 'muc', 'the exchange');
|
||||
assert.ok(find('germany').length <= ev('FIND_N'), 'a short list');
|
||||
assert.equal(ev("findCities('zzqqxx').length"), 0);
|
||||
// Names first, then countries: "san" finds San José before cities in some country with "san" in it.
|
||||
assert.equal(ev("findCities('san').every((c,i,a)=>i===0||fold(CITY[a[i-1]].name).includes('san')||!fold(CITY[c].name).includes('san'))"), true);
|
||||
// An empty box lists your own POPs.
|
||||
assert.equal(ev("findCities('').join()"), ev("Object.keys(S.pops).join()"));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the search box opens with / or the HUD button, Enter jumps to the first city, Escape closes', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
const doc = dom.window.document;
|
||||
ev(start);
|
||||
const key = (k, t) => (t || doc.body).dispatchEvent(new dom.window.KeyboardEvent('keydown', { key: k, bubbles: true }));
|
||||
key('/');
|
||||
assert.equal(ev("$('modal').hidden"), false, '/ opens it');
|
||||
assert.ok(doc.getElementById('findIn'), 'with a search field');
|
||||
const inp = doc.getElementById('findIn');
|
||||
inp.value = 'tokyo';
|
||||
inp.dispatchEvent(new dom.window.Event('input', { bubbles: true }));
|
||||
assert.match(doc.getElementById('findList').textContent, /Tokyo/);
|
||||
key('Enter', inp);
|
||||
assert.equal(ev("$('modal').hidden"), true, 'Enter jumps');
|
||||
assert.equal(ev('UI.sel&&UI.sel.id||UI.sel'), 'tok', 'and selects Tokyo');
|
||||
assert.equal(ev('cam.x'), ev('CITY.tok.x'), 'with the map on it');
|
||||
// The HUD button, then a tap on a result.
|
||||
doc.querySelector('#hud .chip.find').click();
|
||||
assert.equal(ev("$('modal').hidden"), false);
|
||||
const i2 = doc.getElementById('findIn');
|
||||
i2.value = 'nowhere at all';
|
||||
i2.dispatchEvent(new dom.window.Event('input', { bubbles: true }));
|
||||
assert.match(doc.getElementById('findList').textContent, /No city matches/);
|
||||
key('Escape', i2);
|
||||
assert.equal(ev("$('modal').hidden"), true, 'Escape closes');
|
||||
ev("ACT.findOpen();ACT.findGo({city:'syd'})");
|
||||
assert.equal(ev('cam.x'), ev('CITY.syd.x'));
|
||||
ev("ACT.findGo({city:'atlantis'})");
|
||||
assert.equal(ev('cam.x'), ev('CITY.syd.x'), 'unknown ids are ignored');
|
||||
// Typing / in another text field types a slash.
|
||||
ev("ACT.rename()");
|
||||
key('/', doc.getElementById('rnIn'));
|
||||
assert.equal(ev("!!$('findIn')"), false);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('in German, a German country name finds the city, and the search works on a phone', () => {
|
||||
const { ev, dom, errors } = load({ lang: 'de' });
|
||||
ev(start + ";if(ACT.pitchSkip)ACT.pitchSkip();window.innerWidth=360;ACT.findOpen()");
|
||||
assert.ok(ev("findCities('deutschland').includes('fra')"), 'Deutschland');
|
||||
assert.ok(ev("findCities('germany').includes('fra')"), 'and Germany still works');
|
||||
assert.match(dom.window.document.getElementById('modalCard').textContent, /Stadt finden/);
|
||||
assert.doesNotMatch(dom.window.document.getElementById('modalCard').textContent, /\/ /, 'no keyboard tip on a phone');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
184
tests/philippines.test.js
Normal file
184
tests/philippines.test.js
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
// The Philippines: Manila's exchanges and networks, Cebu, Davao and the cables that really land there.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert');
|
||||
const { load } = require('./harness');
|
||||
|
||||
function start(ev) { ev("ACT.start({});S.cash=1e9;S.lvl=6;for(const g of GOALS)S.done[g.id]=0"); }
|
||||
const ids = (ev, js) => JSON.parse(ev(`JSON.stringify(${js})`));
|
||||
|
||||
test('Manila: GotchaFIX, Bayanihan-IX and the incumbent-run In-Vitro-IX', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
assert.equal(ev('CITY.mnl.ix'), 'GotchaFIX Manila');
|
||||
assert.equal(ev("XIXM['mnl~2'].name"), 'Bayanihan-IX');
|
||||
assert.equal(ev("XIXM['mnl~3'].name"), 'In-Vitro-IX');
|
||||
// the neutral exchange has the open networks, not the PLDT family
|
||||
const gotcha = ids(ev, "ixMembers('mnl')");
|
||||
for (const n of ['glb', 'cvg', 'dto']) assert.ok(gotcha.includes(n), `${n} on GotchaFIX`);
|
||||
assert.ok(!gotcha.includes('pld') && !gotcha.includes('smt'));
|
||||
assert.ok(gotcha.length >= 10, `GotchaFIX has ${gotcha.length} members`);
|
||||
// the incumbent's own exchange is PLDT and its mobile arm
|
||||
const vitro = ids(ev, "ixMembers('mnl~3')");
|
||||
assert.ok(vitro.includes('pld') && vitro.includes('smt'));
|
||||
assert.ok(ids(ev, "ixMembers('mnl~2')").includes('dto'));
|
||||
// GetaFIX's price list: 10G for $700 and 100G for $2,800 a month, within a few percent
|
||||
for (const c of ['mnl', 'ceb', 'dvo']) {
|
||||
ev(`ACT.buildPop({city:'${c}'})`);
|
||||
assert.ok(Math.abs(ev(`ixPortMo('${c}',0)`) - 700) <= 35, `${c} 10G is ${ev(`ixPortMo('${c}',0)`)}`);
|
||||
assert.ok(Math.abs(ev(`ixPortMo('${c}',1)`) - 2800) <= 140, `${c} 100G is ${ev(`ixPortMo('${c}',1)`)}`);
|
||||
}
|
||||
// the community exchange is the cheapest port in town, the incumbent's the dearest
|
||||
assert.ok(ev("ixMul('mnl~2')<ixMul('mnl')&&ixMul('mnl')<ixMul('mnl~3')"));
|
||||
// the incumbent charges double GotchaFIX's price
|
||||
assert.equal(ev("ixPortMo('mnl~3',0)"), 1760);
|
||||
assert.equal(ev("ixPortMo('mnl~3',1)"), 6600);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Manila: PLDTea Time and Globe-Trotter Telecom sell transit; a PLDT PNI also reaches Smarty Pants', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
assert.ok(ev("sellsAt(NET.pld,'mnl')&&sellsAt(NET.glb,'mnl')"));
|
||||
assert.ok(ev("!sellsAt(NET.cvg,'mnl')&&!sellsAt(NET.dto,'mnl')&&!sellsAt(NET.smt,'mnl')"));
|
||||
assert.deepEqual(ids(ev, 'PNI_NETS.pld').sort(), ['pld', 'smt']);
|
||||
assert.equal(ev('NET.pld.pol'), 'selective');
|
||||
assert.equal(ev('NET.cvg.pol') + ev('NET.dto.pol'), 'openopen');
|
||||
assert.equal(ev('NET.glb.pol'), 'selective', 'Globe-Trotter Telecom stays selective');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Manila: an exchange the player founded there before GotchaFIX existed keeps working', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
ev("ACT.buildPop({city:'mnl'});S.myIx.mnl={name:'Mine-IX Manila',members:['dto','tail0'],next:0};S.ixp.mnl=2");
|
||||
ev('const o=JSON.parse(JSON.stringify(S));sanitize(o);window.__o=o');
|
||||
assert.equal(ev('__o.myIx.mnl.name'), 'Mine-IX Manila');
|
||||
ev('S=__o;after()');
|
||||
assert.equal(ev("ixName('mnl')"), 'Mine-IX Manila');
|
||||
assert.deepEqual(ids(ev, "ixMembers('mnl')"), ['dto', 'tail0']);
|
||||
// and nobody can found a second one now that a real exchange runs in Manila
|
||||
ev("delete S.myIx.mnl;delete S.ixp.mnl;ACT.foundIx({city:'mnl'})");
|
||||
assert.ok(ev('!S.myIx.mnl'));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Manila: RISE & Shine peers openly on all three Manila exchanges, across Asia and in Europe', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
assert.equal(ev('NET.rsh.name'), 'RISE & Shine');
|
||||
assert.equal(ev('NET.rsh.pol'), 'open');
|
||||
// GetaFIX Manila, PhOpenIX and VIX, Singapore, Hong Kong, DE-CIX, AMS-IX, LINX, Netnod. Tokyo and Los Angeles are left
|
||||
// out: an open eyeball network there makes the Stepping Stones scenario too easy.
|
||||
for (const x of ['mnl', 'mnl~2', 'mnl~3', 'sin', 'sin~2', 'hkg', 'hkg~2', 'fra', 'ams', 'lon', 'sto'])
|
||||
assert.ok(ids(ev, `ixMembers('${x}')`).includes('rsh'), `RISE & Shine on ${x}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Cebu: its own island, GotchaFIX Cebu, reached by two domestic cables, in the typhoon belt', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
assert.ok(ev("isSub('ceb','mnl')"), 'Cebu is an island');
|
||||
assert.ok(ev('onLand(CITY.ceb.x,CITY.ceb.y)'), 'Cebu is drawn on land');
|
||||
assert.equal(ev('CITY.ceb.ix'), 'GotchaFIX Cebu');
|
||||
assert.equal(ev('CITY.ceb.dc'), "Magellan's Last Rack");
|
||||
assert.deepEqual(ids(ev, "cablesFor('mnl','ceb').map(p=>p.cid)").sort(), ['dfon', 'pdscn']);
|
||||
for (const n of ['pld', 'glb']) assert.ok(ev(`sellsAt(NET.${n},'ceb')`), `${n} sells transit in Cebu`);
|
||||
assert.ok(ev("NET.cvg.pops.includes('ceb')"));
|
||||
// a subsea wave from Manila to Cebu carries traffic
|
||||
for (const c of ['mnl', 'ceb']) ev(`ACT.buildPop({city:'${c}'});S.pops.${c}.rgen=3`);
|
||||
ev("UI.via='pdscn';UI.route='same';openLinkModal('mnl','ceb');ACT.buildLink({tier:2});closeModal()");
|
||||
ev('compute()');
|
||||
assert.equal(ev("S.links.filter(l=>l.sub&&l.cable==='pdscn').length"), 1);
|
||||
// typhoons can now hit a Cebu PoP
|
||||
ev("S.pops={ceb:S.pops.ceb};delete S.pops.ceb.gen;for(let i=0;i<2000&&!(S.pops.ceb.down>S.day);i++)fireEvent()");
|
||||
assert.ok(ev("S.pops.ceb.down>S.day&&S.inc.some(i=>i.type==='power'&&i.ref==='ceb')"), 'a typhoon knocked out Cebu');
|
||||
ev('cam.z=5;cam.x=CITY.ceb.x;cam.y=CITY.ceb.y;draw(0)');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Davao: Mindanao, GotchaFIX Davao, the trans-Pacific landings moved from Manila, and cables from Cebu', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
assert.ok(ev("isSub('dvo','mnl')&&isSub('dvo','ceb')"), 'Davao is on Mindanao');
|
||||
assert.ok(ev('onLand(CITY.dvo.x,CITY.dvo.y)'), 'Davao is drawn on land');
|
||||
assert.equal(ev('CITY.dvo.ix'), 'GotchaFIX Davao');
|
||||
assert.equal(ev('CITY.dvo.dc'), "Heimdall's Hut");
|
||||
// Bi-Frosted's Philippine branch and SEA-US land at Davao, not Manila
|
||||
const at = (cid, c) => ids(ev, `CABLE_PAIRS.filter(p=>p.cid==='${cid}'&&(p.a==='${c}'||p.b==='${c}')).map(p=>p.a==='${c}'?p.b:p.a)`).sort();
|
||||
assert.deepEqual(at('bifrost', 'mnl'), []);
|
||||
assert.deepEqual(at('bifrost', 'dvo'), ['gum', 'jkt']);
|
||||
assert.deepEqual(at('seaus', 'mnl'), []);
|
||||
assert.deepEqual(at('seaus', 'dvo'), ['gum']);
|
||||
assert.ok(ev("cablesFor('jkt','gum').some(p=>p.cid==='bifrost')&&cablesFor('gum','lax').some(p=>p.cid==='bifrost')"), 'the trunk stays');
|
||||
assert.deepEqual(ids(ev, "cablesFor('ceb','dvo').map(p=>p.cid)").sort(), ['dfon', 'pdscn', 'vismin']);
|
||||
// PDSCN's Luzon–Mindanao segment runs the whole way, so Manila reaches Davao in one hop
|
||||
assert.deepEqual(ids(ev, "cablesFor('mnl','dvo').map(p=>p.cid)"), ['pdscn']);
|
||||
for (const n of ['pld', 'glb']) assert.ok(ev(`sellsAt(NET.${n},'dvo')`), `${n} sells transit in Davao`);
|
||||
assert.ok(ev("NET.cvg.pops.includes('dvo')"));
|
||||
ev('cam.z=5;cam.x=CITY.dvo.x;cam.y=CITY.dvo.y;draw(0)');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Davao: a saved link on a Bi-Frosted or SEA-US pair that moved keeps working, without the cable', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
for (const c of ['mnl', 'jkt', 'hkg']) ev(`ACT.buildPop({city:'${c}'});S.pops.${c}.rgen=3`);
|
||||
ev("UI.via='sjcph';UI.route='same';openLinkModal('mnl','hkg');ACT.buildLink({tier:2});closeModal()");
|
||||
ev("UI.via='sjcph';UI.route='same';openLinkModal('mnl','hkg');ACT.buildLink({tier:2});closeModal()");
|
||||
assert.equal(ev('S.links.length'), 2);
|
||||
// as an old save had them: Bi-Frosted Jakarta–Manila and an untouched Manila–Hong Kong link
|
||||
ev("const l=S.links[0];l.a='jkt';l.b='mnl';l.km=kmBetween('jkt','mnl');l.cable='bifrost'");
|
||||
ev('const o=JSON.parse(JSON.stringify(S));sanitize(o);window.__o=o');
|
||||
assert.equal(ev('__o.links.length'), 2, 'the link survives');
|
||||
assert.equal(ev("__o.links.find(l=>l.a==='jkt').cable"), null, 'its cable tag is dropped');
|
||||
assert.equal(ev("__o.links.find(l=>l.b==='hkg').cable"), 'sjcph', 'a pair that still exists keeps its cable');
|
||||
ev('S=__o;after();compute()');
|
||||
ev('cam.z=1;draw(0)');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Cebu and Davao: RISE & Shine is on GotchaFIX Cebu and GotchaFIX Davao', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
for (const c of ['ceb', 'dvo']) assert.ok(ids(ev, `ixMembers('${c}')`).includes('rsh'), `RISE & Shine on ${c}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the Philippines: transit about 1.9 times the Asian rate, homes pay about US$25 a month', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
for (const c of ['mnl', 'ceb', 'dvo']) {
|
||||
assert.equal(ev(`regionMult('${c}')`), ev('PH_TRANSIT'), `${c} pays the Philippine transit rate`);
|
||||
assert.equal(ev(`CITY.${c}.arpu`), ev('PH_ARPU'));
|
||||
}
|
||||
// Manila's 100 GigE transit is about 1.9 times Jakarta's
|
||||
assert.ok(Math.abs(ev("regionMult('mnl')/regionMult('jkt')") - 1.9) < 0.1);
|
||||
assert.equal(ev("regionMult('sin')"), 2.5, 'the rest of Asia is unchanged');
|
||||
// the same transit port costs more in Manila than in Jakarta
|
||||
ev("ACT.buildPop({city:'mnl'});ACT.buildPop({city:'jkt'})");
|
||||
assert.ok(ev("transitMo({net:'sgt',city:'mnl',tier:1},10)>transitMo({net:'sgt',city:'jkt',tier:1},10)"));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Philippines: waves between the islands cost more than waves out of the country', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
// cheapest 10G wave on any cable between two cities
|
||||
const w = (a, b) => ev(`Math.min(...cablesOk('${a}','${b}').map(c=>waveMo(c.km,true,0)*CAB[c.cid].price*waveMarket('${a}','${b}',true).m))`);
|
||||
assert.equal(ev("waveMarket('mnl','ceb',true).reg"), ev('PH_WAVE'));
|
||||
assert.equal(ev("waveMarket('mnl','hkg',true).reg"), 1.5, 'international routes keep the Asian rate');
|
||||
const ratio = w('mnl', 'ceb') / w('mnl', 'hkg');
|
||||
assert.ok(ratio > 1.8 && ratio < 2.2, `Manila–Cebu is ${ratio.toFixed(2)} times Manila–Hong Kong`);
|
||||
assert.ok(w('ceb', 'dvo') > w('mnl', 'hkg'), 'even the short Cebu–Davao hop costs more than Hong Kong');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Philippines: eyeballs at about 40G per million people, like the rest of the map', () => {
|
||||
const { ev, errors } = load();
|
||||
// Demographia 2022 urban area for Manila, the 2020 census for Metro Cebu and Metro Davao
|
||||
for (const [c, millions] of [['mnl', 24.9], ['ceb', 3.17], ['dvo', 3.34]]) {
|
||||
const perM = ev(`CITY.${c}.P`) / millions;
|
||||
assert.ok(perM > 37 && perM < 43, `${c} has ${perM.toFixed(1)}G per million people`);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
@ -596,6 +596,30 @@ test('#228 the intern names the exchanges it peered at, even one that shares its
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#227 transit "Already connected" grows the providers you have, the smallest first, and never signs a new one', t => {
|
||||
const { ev, errors } = game(t, "ACT.buyTransit({city:'fra',net:'ntt',tier:1});compute()");
|
||||
hire(ev); on(ev, 'transit', { x: 1.5, prov: 'have' });
|
||||
const capOf = net => ev(`(()=>{const t=S.transit.find(x=>x.city==='fra'&&x.net==='${net}');return lagCap(PORT[t.tier].g,t.n)})()`);
|
||||
const c0 = capOf('cog'), n0 = capOf('ntt');
|
||||
assert.equal(c0, n0, 'two equal ports to start');
|
||||
ev('for(const t of S.transit)t.hist=[100]'); shift(ev);
|
||||
assert.equal(ev("JSON.stringify(S.transit.filter(t=>t.city==='fra').map(t=>t.net).sort())"), '["cog","ntt"]', 'no new provider');
|
||||
assert.ok(capOf('cog') > c0 && capOf('ntt') > n0, 'both grew, not just one');
|
||||
assert.equal(capOf('cog'), capOf('ntt'), 'evenly, smallest first');
|
||||
// a POP whose only upstream is not the cheapest never gets the cheapest added (Cheapest would buy Cogentle there)
|
||||
ev("ACT.buildPop({city:'ams'});S.pops.ams.rgen=1;ACT.launchBB({city:'ams'});ACT.buyTransit({city:'ams',net:'ntt',tier:1});compute()");
|
||||
assert.equal(ev("cheapestTransit('ams').id"), 'cog');
|
||||
ev("for(const t of S.transit)t.hist=[400]"); ev('S.day++'); shift(ev);
|
||||
assert.equal(ev("JSON.stringify(S.transit.filter(t=>t.city==='ams').map(t=>t.net))"), '["ntt"]');
|
||||
// the setting cycles through it, reads "Already connected" and survives a save
|
||||
ev("S.ops.p.transit.prov='cheap';ACT.opsParam({k:'transit',p:'prov'})");
|
||||
assert.equal(ev("opsP('transit','prov')"), 'have');
|
||||
assert.equal(ev("opsVal('transit','prov')"), 'Already connected');
|
||||
ev('S=migrate(JSON.parse(JSON.stringify(S)))');
|
||||
assert.equal(ev("opsP('transit','prov')"), 'have');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#244 the PNI order counts the traffic the PNI list shows at that POP, not what cache boxes there already serve', t => {
|
||||
const { ev, errors } = game(t, "ACT.buildPop({city:'ham'});for(const c of ['fra','ham']){S.pops[c].rgen=mainRG(4);S.pops[c].routers=6;if(!S.pops[c].bb)ACT.launchBB({city:c});S.pops[c].bb.d=CITY[c].P*0.9;}UI.pending={a:'fra',b:'ham'};ACT.buildLink({tier:3});closeModal();ACT.buyTransit({city:'fra',net:'cog',tier:3});ACT.buyTransit({city:'ham',net:'cog',tier:3});for(let i=0;i<6;i++)S.caches.push({id:'nfx'+i,city:'ham',net:'nfx'});compute()");
|
||||
// Hamburg's users want a lot from NetChill, but its cache boxes there serve most of it: little is left for a PNI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue