From 24d865aa57ae8afe32b6f45a1297d34f0f80b316 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 4 Nov 2026 08:11:03 +0100 Subject: [PATCH] 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. --- site/i18n/de.js | 1 + site/i18n/es.js | 1 + site/i18n/fr.js | 1 + site/i18n/it.js | 1 + site/i18n/pt.js | 1 + src/game/60-features/50-traceroute.js | 2 +- src/game/70-rules/60-de-kicks.js | 7 ++++--- src/game/80-simulation/50-sanitize.js | 3 +++ src/game/90-actions/21-ix-downgrade.js | 5 +++-- src/game/93-ui/52-pni-list.js | 2 +- src/i18n/en.js | 1 + tests/de-kicks-price-cap.test.js | 21 +++++++++++++++++++++ tests/ix-downgrade.test.js | 8 ++++++-- tests/traceroute-modes.test.js | 11 +++++++++++ 14 files changed, 56 insertions(+), 9 deletions(-) diff --git a/site/i18n/de.js b/site/i18n/de.js index 99ef84a..36144e8 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -4069,6 +4069,7 @@ "traceroute.the_carrier_s_own_port_beats_other":"Dieser Port führt direkt zu {net} und schlägt daher die anderen Transit-Ports.", "traceroute.this_one_is_set_to_mode":"; dieser steht auf {mode}", "traceroute.transit_is_the_last_resort":"Transit ist der letzte Ausweg", +"traceroute.your_traffic_follows_the_metrics_this":"Dein Internetverkehr folgt den Metriken. Dies ist der Weg, den eine Kundenleitung auf „{mode}“ nehmen würde.", "tutorial.businesses_pop_up_as_bubbles_on":"Unternehmen tauchen als $-Blasen auf der Karte auf. Öffne Deals und gewinne deinen ersten Kunden.", "tutorial.grow_drag_from_your_pink_router":"Wachse: Zieh von deiner Stadt zu einer Stadt in der Nähe, um Glasfaser zu verlegen und einen zweiten POP zu eröffnen.", "tutorial.start_the_clock_with_1_and":"Starte die Uhr mit 1× und sieh zu, wie Traffic und Geld fließen. Du kannst jederzeit pausieren.", diff --git a/site/i18n/es.js b/site/i18n/es.js index f880db3..baba114 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -4067,6 +4067,7 @@ "traceroute.the_carrier_s_own_port_beats_other":"Este puerto va directo a {net}, así que gana a los otros puertos de tránsito.", "traceroute.this_one_is_set_to_mode":"; esta está en {mode}", "traceroute.transit_is_the_last_resort":"el tránsito es el último recurso", +"traceroute.your_traffic_follows_the_metrics_this":"Tu tráfico de internet sigue las métricas. Este es el camino que tomaría un circuito de cliente en «{mode}».", "tutorial.businesses_pop_up_as_bubbles_on":"Las empresas aparecen como burbujas de $ en el mapa. Abre Tratos y firma a tu primer cliente.", "tutorial.grow_drag_from_your_pink_router":"Crece: arrastra desde tu router rosa hasta una ciudad cercana para tender fibra y abrir un segundo POP.", "tutorial.start_the_clock_with_1_and":"Pon el reloj en marcha con 1× y mira cómo fluyen el tráfico y el dinero. Puedes pausar cuando quieras.", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index a78afb5..263018f 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -4067,6 +4067,7 @@ "traceroute.the_carrier_s_own_port_beats_other":"Ce port mène directement chez {net}, donc il passe avant les autres ports de transit.", "traceroute.this_one_is_set_to_mode":" ; celle-ci est réglée sur {mode}", "traceroute.transit_is_the_last_resort":"le transit est le dernier recours", +"traceroute.your_traffic_follows_the_metrics_this":"Ton trafic internet suit les métriques. Voici le chemin que prendrait un circuit client en « {mode} ».", "tutorial.businesses_pop_up_as_bubbles_on":"Les entreprises apparaissent sous forme de bulles $ sur la carte. Ouvre Offres et signe ton premier client.", "tutorial.grow_drag_from_your_pink_router":"Grandis : fais glisser depuis ton routeur rose vers une ville proche pour poser de la fibre et ouvrir un deuxième POP.", "tutorial.start_the_clock_with_1_and":"Lance le temps en 1× et regarde le trafic et l’argent couler. Tu peux mettre en pause à tout moment.", diff --git a/site/i18n/it.js b/site/i18n/it.js index d2610b9..7fe478b 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -4067,6 +4067,7 @@ "traceroute.the_carrier_s_own_port_beats_other":"Questa porta va direttamente a {net}, quindi batte le altre porte di transit.", "traceroute.this_one_is_set_to_mode":"; questa è impostata su {mode}", "traceroute.transit_is_the_last_resort":"il transit è l’ultima spiaggia", +"traceroute.your_traffic_follows_the_metrics_this":"Il tuo traffico internet segue le metriche. Questo è il percorso che prenderebbe un circuito cliente su «{mode}».", "tutorial.businesses_pop_up_as_bubbles_on":"Le aziende spuntano come bolle $ sulla mappa. Apri Offerte e firma il tuo primo cliente.", "tutorial.grow_drag_from_your_pink_router":"Cresci: trascina dal tuo router rosa su una città vicina per posare fibra e aprire un secondo POP.", "tutorial.start_the_clock_with_1_and":"Fai partire il tempo con 1× e guarda scorrere traffico e soldi. Puoi mettere in pausa quando vuoi.", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 1d923e8..64f78e1 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -4067,6 +4067,7 @@ "traceroute.the_carrier_s_own_port_beats_other":"Esta porta vai direto para {net}, então vence as outras portas de transit.", "traceroute.this_one_is_set_to_mode":"; esta está configurada como {mode}", "traceroute.transit_is_the_last_resort":"transit é o último recurso", +"traceroute.your_traffic_follows_the_metrics_this":"O teu tráfego de internet segue as métricas. Este é o caminho que um circuito de cliente em «{mode}» tomaria.", "tutorial.businesses_pop_up_as_bubbles_on":"Empresas aparecem como bolhas de $ no mapa. Abra Negócios e feche seu primeiro cliente.", "tutorial.grow_drag_from_your_pink_router":"Cresça: arraste do seu router rosa até uma cidade próxima para lançar fibra e abrir um segundo POP.", "tutorial.start_the_clock_with_1_and":"Comece o relógio em 1× e veja o tráfego e o dinheiro fluírem. Dá pra pausar a qualquer momento.", diff --git a/src/game/60-features/50-traceroute.js b/src/game/60-features/50-traceroute.js index 1687f8f..89900cd 100644 --- a/src/game/60-features/50-traceroute.js +++ b/src/game/60-features/50-traceroute.js @@ -56,6 +56,6 @@ function traceModal(src,to,mode){const pops=Object.keys(S.pops).sort((a,b)=>CITY
${btn(tr('common.run'),'traceRun',{},'pink sm')}
${tr('common.route_4a2e')}${TR_MODES.map(m=>btn(RT[m],'traceMode',{m},mode===m?'pink sm':'ghost sm')).join('')}
-
${esc(r.text)}
${r.asPath?`

${tr('traceroute.as_path_path',{path:r.asPath.map(a=>'AS'+a).join(' → ')})}

`:''}

${esc(r.why)}

+ ${mode!=='normal'?`

${tr('traceroute.your_traffic_follows_the_metrics_this',{mode:RT[mode]})}

`:''}
${esc(r.text)}
${r.asPath?`

${tr('traceroute.as_path_path',{path:r.asPath.map(a=>'AS'+a).join(' → ')})}

`:''}

${esc(r.why)}

${btn(tr('common.copy'),'traceCopy',{},'ghost sm')}
`);UI.trText=r.text;} diff --git a/src/game/70-rules/60-de-kicks.js b/src/game/70-rules/60-de-kicks.js index 322e2fc..03438aa 100644 --- a/src/game/70-rules/60-de-kicks.js +++ b/src/game/70-rules/60-de-kicks.js @@ -6,10 +6,11 @@ const isDk=c=>(DK_CITIES.includes(c)||scnRule('dkAll'))&&!!CITY[c]&&!!CITY[c].ix const DK_ADDONS=[['Blackholing Plus™',tr('de_kicks.like_blackholing_but_with_a_plus')],['Route Server Gold',tr('de_kicks.the_same_route_server_in_a')],['Premium Port LEDs',tr('de_kicks.your_port_light_now_blinks_in')],['Strategic Peering Insights',tr('de_kicks.a_monthly_pdf_of_your_own')],['GlobePeer Ready™',tr('de_kicks.makes_your_port_ready_for_a')],['Cloud Exchange Readiness Fee',tr('de_kicks.a_fee_for_being_ready_for')],['Account Manager Lunch Fund',tr('de_kicks.your_account_manager_is_hungry')]]; const DK_STALL=[tr('de_kicks.your_account_manager_would_love_to'),tr('de_kicks.pricing_is_reviewed_by_the_global'),tr('de_kicks.they_sent_a_14_page_nda'),tr('de_kicks.your_account_manager_is_at_a')]; // Harmonisation and ended promos raise the personal price, but only up to this multiple of the list price: uncapped, 8-15% a -// year turned a 60-year game into $100k ports. (ponytail: a guess at the ceiling; the maintainer can tune it.) +// year turned a 60-year game into $100k ports. Saves are clamped in sanitize(), remembered quotes too. const DK_MAX=4; function dkMult(c){if(!S||!isDk(c)||!S.dk||!S.dk.m[c])return 1;const ret=S.dk.ret[c];return Math.min(S.dk.m[c],DK_MAX)*(ret&&ret>S.day?0.6:1);} -function dkRaise(c,f){const dk=S.dk,was=Math.min(dk.m[c],DK_MAX);dk.m[c]=Math.min(DK_MAX,+(dk.m[c]*f).toFixed(3));return dk.m[c]>was;} +// The rise that actually happened (1 at the ceiling), so a toast never announces more than the bill shows. +function dkRaise(c,f){const dk=S.dk,was=Math.min(dk.m[c],DK_MAX);dk.m[c]=Math.min(DK_MAX,+(dk.m[c]*f).toFixed(3));return dk.m[c]/was;} function dkAddonMo(c){return S.dk&&S.dk.add[c]?S.dk.add[c].reduce((a,x)=>a+x.mo,0):0;} function dkState(){S.dk=S.dk||{m:{},add:{},ret:{},retUsed:{},stall:0,q:null};return S.dk;} function dkQuoteMult(){const pops=Object.keys(S.pops).length,big=Math.min(1.2,pops*0.04+(R.served||0)/20000);return +(0.95+Math.random()*0.45+big).toFixed(2);} @@ -24,7 +25,7 @@ function dkQuoteModal(){const q=S.dk.q,c=q.city,mo=Math.round(PORT[q.tier].ix*(S function dkTick(d){if(!S.dk)return;const dk=S.dk; for(const c in S.ixp){if(!isDk(c))continue; if(dk.ret[c]&&dk.ret[c]===d){dkRaise(c,1.1);toast(tr('de_kicks.your_ix_promo_ended_price_is',{ix:esc(ixName(c))}),'bad');} - if(dk.m[c]&&(d+hstr(c)%90)%365===0){const f=1.08+Math.random()*0.07;if(dkRaise(c,f))toast(tr('de_kicks.de_kicks_has_harmonised_its_prices',{ix:esc(ixName(c)),p:Math.round((f-1)*100)}),'bad');} + if(dk.m[c]&&(d+hstr(c)%90)%365===0){const r=dkRaise(c,1.08+Math.random()*0.07),p=Math.round((r-1)*100);if(p>0)toast(tr('de_kicks.de_kicks_has_harmonised_its_prices',{ix:esc(ixName(c)),p}),'bad');} const add=dk.add[c]=dk.add[c]||[]; if(add.length<3&&Math.random()<1/150){const a=DK_ADDONS.filter(x=>!add.some(y=>y.n===x[0]));if(a.length){const [n,blurb]=pick(a),mo=Math.round((300+Math.random()*1200)/50)*50;add.push({n,blurb,mo,day:d}); toast(tr('de_kicks.good_news_you_ve_been_enrolled',{addon:esc(n),blurb:esc(blurb),price:fmt$(mo),ix:esc(ixName(c))}),'bad');}}} diff --git a/src/game/80-simulation/50-sanitize.js b/src/game/80-simulation/50-sanitize.js index a8c6d75..6d25862 100644 --- a/src/game/80-simulation/50-sanitize.js +++ b/src/game/80-simulation/50-sanitize.js @@ -46,6 +46,9 @@ function sanitize(s){ {const sp={};if(s.spares&&typeof s.spares==='object')for(const k in s.spares)if(own(OPT,k)){const v=Math.floor(+s.spares[k]);if(v>0)sp[k]=Math.min(999,v);}s.spares=sp;} s.caches=s.caches.filter(x=>x&&isCity(x.city)&&isNet(x.net)&&NET[x.net].cache).map(x=>(x.id=sid(x.id),x.site=x.site==='b'&&s.pops[x.city]&&s.pops[x.city].site2?'b':'a',x.g===CACHE_BIG?x.g=CACHE_BIG:delete x.g,x)); for(const c of Object.keys(s.ixp)){if(!isIx(c))delete s.ixp[c];else s.ixp[c]=tier(s.ixp[c]);} + // DE-Kicks personal prices: only numbers, and none above the ceiling (older saves compounded them without one). + if(s.dk&&typeof s.dk==='object'){const dk=s.dk;for(const k of ['m','lastQ'])if(dk[k]&&typeof dk[k]==='object'){for(const c of Object.keys(dk[k])){const v=k==='m'?dk[k][c]:dk[k][c]&&dk[k][c].m; + if(!(typeof v==='number'&&v>0&&isFinite(v)))delete dk[k][c];else if(k==='m')dk.m[c]=Math.min(v,DK_MAX);else dk.lastQ[c].m=Math.min(v,DK_MAX);}}else if(k==='m')dk.m={};} for(const k of ['rs','ixn','ixPref','ixSite'])for(const c of Object.keys(s[k]))if(!isIx(c))delete s[k][c];if(s.ixCut&&typeof s.ixCut==='object'){for(const c of Object.keys(s.ixCut))if(!isIx(c))delete s.ixCut[c];else s.ixCut[c]=Math.min(1,Math.max(0.6,num(s.ixCut[c],1)));}else delete s.ixCut; for(const c of Object.keys(s.ixn))s.ixn[c]=lag(s.ixn[c]);for(const c of Object.keys(s.ixSite))if(!['a','b','ab'].includes(s.ixSite[c]))s.ixSite[c]='a'; for(const k of Object.keys(s.peers)){const [n,c]=k.split('@');if(!isNet(n)||!isIx(c))delete s.peers[k];} diff --git a/src/game/90-actions/21-ix-downgrade.js b/src/game/90-actions/21-ix-downgrade.js index d65cd23..efb9f79 100644 --- a/src/game/90-actions/21-ix-downgrade.js +++ b/src/game/90-actions/21-ix-downgrade.js @@ -1,9 +1,10 @@ -/* Step a port down one size: exchange ports, transit ports and PNIs. Upgrading was possible, downsizing meant leaving and rejoining. */ +/* Step a port down one size: exchange ports, transit ports and PNIs. Upgrading was possible, downsizing meant leaving and rejoining. + A PNI stops at the smallest size the network sells (Tier 1s and closed CDNs: no 10G). */ Object.assign(ACT,{ downIx:({city})=>{const had=S.ixp[city];if(had===undefined||S.myIx[city]||!(had>0))return; S.ixp[city]=had-1;toast(tr('ix_downgrade.port_downgraded_at_ix',{port:PORT[had-1].n,ix:esc(ixName(city))}),'good');sfx('click');after();}, downT:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t||!(t.tier>0))return;t.tier--; toast(tr('ix_downgrade.transit_downgraded',{net:esc(NET[t.net].name),city:CITY[t.city].name,port:lagName(t.tier,t.n)}),'good');sfx('click');after();}, - downP:({id})=>{const p=S.pni.find(x=>x.id===id);if(!p||!pniOn(p)||p.up||p.g1||!(p.tier>0))return;p.tier--; + downP:({id})=>{const p=S.pni.find(x=>x.id===id);if(!p||!pniOn(p)||p.up||p.g1||!(p.tier>pniMin(p.net)))return;p.tier--; toast(tr('ix_downgrade.pni_downgraded',{net:esc(NET[p.net].name),city:CITY[p.city].name,port:pniPN(p)}),'good');sfx('click');after();}, }); diff --git a/src/game/93-ui/52-pni-list.js b/src/game/93-ui/52-pni-list.js index 381c9fa..40f85f1 100644 --- a/src/game/93-ui/52-pni-list.js +++ b/src/game/93-ui/52-pni-list.js @@ -11,7 +11,7 @@ function pniValLine(n,c,v){ return `
${tr('pni_list.n_here',{g:fmtG(v.want)})}: ${via} → ${tr('pni_list.with_port',{port:PORT[v.tier].n,val})}
`;} function pniRow(c,n,pn,v,chk){let h=`
${logo(n)}
${esc(n.name)} ${n.pol}${v&&v.worth?` ⭐ ${tr('pni_list.worth_it')}`:''}
${pniChip(n.id,c)}
${v?pniValLine(n,c,v):''}`; if(pn&&!pniOn(pn))h+=pniWait(pn,c); - else if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(pniG(pn),pn.n);h+=`
${(pn.n||1)>1?`${pn.n}×${pniPN(pn)} LAG`:pniPN(pn)} PNI${fmtG(u)}
${pn.up?`
${tr('city_panel.augment_on_order_port_about_n',{port:(pn.up.n>1?pn.up.n+'×':'')+(pn.up.g1?'1G':PORT[pn.up.tier].n),n:Math.max(0,pn.up.ready-S.day)})} ${btn(tr('common.chase_it'),'pniChase',{id:pn.id},'ghost sm')}
`:''}
${prefCtl('p',pn.id,pn.pref)}${siteCtl('p',pn.id,c,pn.up&&pn.up.site==='ab'?'ab':pn.site)}
${PORT.map((P2,i)=>!pn.up&&!msfNope(n.id,c)&&(i>pn.tier||(pn.g1&&i===0))?btn((a=>(pn.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_cost_mo_mo',a))({port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1)),mo:fmt$(P2.pni*(pn.n||1))}),'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)||S.cash<(1500+P2.setup/2)*(pn.n||1)):'').join('')}${!pn.up&&!pn.g1&&pn.tier>0&&!msfNope(n.id,c)?btn(tr('link_panels.downgrade_port_price',{port:PORT[pn.tier-1].n,price:portMo(PORT[pn.tier-1].pni*(pn.n||1))}),'downP',{id:pn.id},'ghost sm'):''}${(pn.n||1)1?btn(tr('common.member'),'lagP',{id:pn.id,d:-1},'ghost sm'):''}${NET[n.id].cn?btn(pn.sacrif?tr('common.sacrificial_choke'):tr('city_panel.make_sacrificial_contains_floods_1_2'),'sacrif',{id:pn.id},pn.sacrif?'green sm':'sm'):''}${btn(UI.confirm===pn.id?tr('common.really_remove'):tr('common.remove'),'cancelPni',{id:pn.id},'ghost sm')}
`;} + else if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(pniG(pn),pn.n);h+=`
${(pn.n||1)>1?`${pn.n}×${pniPN(pn)} LAG`:pniPN(pn)} PNI${fmtG(u)}
${pn.up?`
${tr('city_panel.augment_on_order_port_about_n',{port:(pn.up.n>1?pn.up.n+'×':'')+(pn.up.g1?'1G':PORT[pn.up.tier].n),n:Math.max(0,pn.up.ready-S.day)})} ${btn(tr('common.chase_it'),'pniChase',{id:pn.id},'ghost sm')}
`:''}
${prefCtl('p',pn.id,pn.pref)}${siteCtl('p',pn.id,c,pn.up&&pn.up.site==='ab'?'ab':pn.site)}
${PORT.map((P2,i)=>!pn.up&&!msfNope(n.id,c)&&(i>pn.tier||(pn.g1&&i===0))?btn((a=>(pn.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_cost_mo_mo',a))({port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1)),mo:fmt$(P2.pni*(pn.n||1))}),'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)||S.cash<(1500+P2.setup/2)*(pn.n||1)):'').join('')}${!pn.up&&!pn.g1&&pn.tier>pniMin(n.id)&&!msfNope(n.id,c)?btn(tr('link_panels.downgrade_port_price',{port:PORT[pn.tier-1].n,price:portMo(PORT[pn.tier-1].pni*(pn.n||1))}),'downP',{id:pn.id},'ghost sm'):''}${(pn.n||1)1?btn(tr('common.member'),'lagP',{id:pn.id,d:-1},'ghost sm'):''}${NET[n.id].cn?btn(pn.sacrif?tr('common.sacrificial_choke'):tr('city_panel.make_sacrificial_contains_floods_1_2'),'sacrif',{id:pn.id},pn.sacrif?'green sm':'sm'):''}${btn(UI.confirm===pn.id?tr('common.really_remove'):tr('common.remove'),'cancelPni',{id:pn.id},'ghost sm')}
`;} else{h+=chk.ok?`
${pniG1(n.id)?btn(tr('city_panel.port_cost_mo_mo',{port:'1G',cost:fmt$(PNI_G1_COST),mo:fmt$(Math.round(PORT[0].pni/2))}),'pni',{city:c,net:n.id,tier:-1},'sm',S.cashportShown(i)&&i>=pniMin(n.id)?btn(tr('city_panel.port_cost_mo_mo',{port:P2.n,cost:fmt$(1500+P2.setup/2),mo:fmt$(P2.pni)}),'pni',{city:c,net:n.id,tier:i},'sm',S.cash<1500+P2.setup/2||!portOk(c,i)):'').join('')}
${pniEta(n.id)}${pniMin(n.id)?' · '+tr('city_panel.no_10g_net_starts_at_100g',{net:esc(n.name)}):pniG1(n.id)?' · '+tr('city_panel.sells_pnis_down_to_1g'):''}
${chk.fee?`
${tr('city_panel.paid_peering_price_mo_on_top',{price:fmt$(chk.fee)})}
`:''}`:`
${esc(chk.why)}
`;} return h+`
`;} function pniListHtml(c){const f=UI.pniF||'all',az=UI.pniSort==='az',open=UI.pniOpen||{}; diff --git a/src/i18n/en.js b/src/i18n/en.js index f39d131..4457050 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -4068,6 +4068,7 @@ "traceroute.the_carrier_s_own_port_beats_other":"This port goes straight to {net}, so it beats the other transit ports.", "traceroute.this_one_is_set_to_mode":"; this one is set to {mode}", "traceroute.transit_is_the_last_resort":"transit is the last resort", +"traceroute.your_traffic_follows_the_metrics_this":"Your internet traffic follows the metrics. This is the path a customer circuit on “{mode}” would take.", "tutorial.businesses_pop_up_as_bubbles_on":"Businesses pop up as $ bubbles on the map. Open Deals and sign your first customer.", "tutorial.grow_drag_from_your_pink_router":"Grow: drag from your pink router onto a nearby city to lay fiber and open a second POP.", "tutorial.start_the_clock_with_1_and":"Start the clock with 1× and watch traffic and money flow. You can pause any time.", diff --git a/tests/de-kicks-price-cap.test.js b/tests/de-kicks-price-cap.test.js index 01b032b..8810b5a 100644 --- a/tests/de-kicks-price-cap.test.js +++ b/tests/de-kicks-price-cap.test.js @@ -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, []); +}); diff --git a/tests/ix-downgrade.test.js b/tests/ix-downgrade.test.js index 524a6fd..ed8c9d4 100644 --- a/tests/ix-downgrade.test.js +++ b/tests/ix-downgrade.test.js @@ -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, []); diff --git a/tests/traceroute-modes.test.js b/tests/traceroute-modes.test.js index c2671f9..22b2c3e 100644 --- a/tests/traceroute-modes.test.js +++ b/tests/traceroute-modes.test.js @@ -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, []); +});