Follow-ups to #276, #277 and #278

Saves clamp a runaway DE-Kicks price and its remembered quote to the ceiling, and a clipped rise announces only what the bill shows.
A PNI steps down only to the smallest size its network sells, so Tier 1 and closed-CDN PNIs stop at 100G.
A trace off the metrics says it shows a customer circuit's path, not where the internet traffic goes.
This commit is contained in:
Frederic Jung 2026-11-04 08:11:03 +01:00
parent c358b715c7
commit 24d865aa57
No known key found for this signature in database
14 changed files with 56 additions and 9 deletions

View file

@ -29,3 +29,24 @@ test('a save that already ran away reads as the ceiling, and a capped price stop
assert.equal(ev("(window.__t||[]).filter(t=>/harmonised/i.test(t)).length"), 0, 'no "prices up" toast at the ceiling');
assert.deepEqual(errors, []);
});
test('loading a save clamps a runaway DE-Kicks price and the quote it remembers, so rejoining is not quoted at 40× list', () => {
const { ev, errors } = load();
ev(start);
ev("S.dk.m.fra=40;S.dk.lastQ={fra:{m:40,h:3,until:S.day+365}};S.dk.m.mad='x';S=sanitize(S)||S");
assert.equal(ev("S.dk.m.fra"), ev("DK_MAX"));
assert.equal(ev("S.dk.lastQ.fra.m"), ev("DK_MAX"));
assert.equal(ev("'mad' in S.dk.m"), false, 'junk is dropped');
assert.deepEqual(errors, []);
});
test('a rise clipped by the ceiling announces only what the bill shows', () => {
const { ev, errors } = load();
ev(start);
ev("S.dk.m.fra=3.9;S.dk.add.fra=[1,2,3]");
const day = ev("(()=>{for(let d=1;d<400;d++)if((d+hstr('fra')%90)%365===0)return d;})()");
ev(`Math.random=()=>0.9;toast=(...a)=>{(window.__t=window.__t||[]).push(a[0])};dkTick(${day})`);
const t = ev("(window.__t||[]).find(t=>/harmonised/i.test(t))||''");
assert.match(t, /\b3\s?%/, `a 3% rise, not 14%: ${t}`);
assert.deepEqual(errors, []);
});

View file

@ -52,8 +52,12 @@ test('a PNI steps down one size at a time, but not while an augment is on order'
assert.equal(ev("S.pni.find(p=>p.id==='pt1').tier"), 1, 'down one size');
ev("S.pni.find(p=>p.id==='pt1').up={tier:1,n:2,ready:S.day+30};ACT.downP({id:'pt1'})");
assert.equal(ev("S.pni.find(p=>p.id==='pt1').tier"), 1, 'an augment on order blocks it');
ev("S.pni.find(p=>p.id==='pt1').up=null;S.pni.find(p=>p.id==='pt1').tier=0;ACT.downP({id:'pt1'})");
assert.equal(ev("S.pni.find(p=>p.id==='pt1').tier"), 0, 'the smallest port stays');
ev("S.pni.find(p=>p.id==='pt1').up=null;ACT.downP({id:'pt1'})");
assert.equal(ev("pniMin('cog')"), 1, 'Cogentle, a Tier 1, sells no 10G PNIs');
assert.equal(ev("S.pni.find(p=>p.id==='pt1').tier"), 1, 'so its PNI stops at 100G');
assert.doesNotMatch(ev("cityPanel('fra')"), /Downgrade 10G/, 'and offers no 10G step');
ev("S.pni.push({id:'pt2',net:'cmc',city:'fra',tier:0});ACT.downP({id:'pt2'})");
assert.equal(ev("S.pni.find(p=>p.id==='pt2').tier"), 0, 'the smallest port stays');
ev("S.pni.find(p=>p.id==='pt1').tier=1;S.pni.find(p=>p.id==='pt1').ready=S.day+9;ACT.downP({id:'pt1'})");
assert.equal(ev("S.pni.find(p=>p.id==='pt1').tier"), 1, 'a PNI that is not up yet stays');
assert.deepEqual(errors, []);

View file

@ -49,3 +49,14 @@ test('the looking glass has the three route buttons, like a customer circuit, an
assert.equal(ev("UI.trMode"), 'fast', 'Run keeps the mode');
assert.deepEqual(errors, []);
});
test('a trace that does not follow the metrics says it shows a circuit’s path, not the internet traffic’s', () => {
const { ev, dom, errors } = load();
const doc = dom.window.document;
setup(ev);
ev("ACT.trace({city:'fra'})");
assert.doesNotMatch(doc.getElementById('modal').textContent, /follows the metrics/);
[...doc.querySelectorAll('[data-act="traceMode"]')][2].click();
assert.match(doc.getElementById('modal').textContent, /follows the metrics\. This is the path a customer circuit on/);
assert.deepEqual(errors, []);
});