Show the cache hop in traceroute only when a cache is the exit

The hop for an embedded cache sat in a bare else, so every trace that
left over transit, an exchange or a PNI without a peer's cone printed
an "embedded cache in your rack" hop, even with no cache box at all.
This commit is contained in:
Charlie Allom 2026-11-03 08:32:00 +00:00
parent de4a750cdd
commit a47fc0735f
No known key found for this signature in database
3 changed files with 23 additions and 1 deletions

21
tests/traceroute.test.js Normal file
View file

@ -0,0 +1,21 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
test('traceroute shows an embedded cache hop only when a cache is the exit', () => {
const { ev, errors } = load();
ev("ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0");
ev("S.pops.fra.bb={d:20/NSH.cfl};ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()");
// The hops, without the "traceroute to …" header line.
const trace = () => { const r = ev("traceroute('fra',{net:'cfl'})"); return { ...r, hops: r.text.split('\n').slice(1).join('\n') }; };
const before = trace();
assert.match(before.why, /Cogentle/, 'over transit');
assert.doesNotMatch(before.hops, /cache-|embedded cache/, 'no cache hop without a cache');
assert.match(before.hops, /www\.crowdflare\.example/, 'ends at the network itself');
ev("ACT.cache({city:'fra',net:'cfl'});compute()");
assert.equal(ev('S.caches.length'), 1);
const after = trace();
assert.match(after.hops, /cache-crowdflare\.fra\..*embedded cache in your rack$/, 'the cache is the last hop');
assert.doesNotMatch(after.hops, /cogentle|www\.crowdflare/, 'nothing leaves the network');
assert.deepEqual(errors, []);
});