feat(fleet): add shared WireGuard profiles and bounded rover transport
Add portable shared WireGuard profiles while retaining Tailscale and Worker boundaries. Bound rover command/telemetry delivery, recovery and diagnostic capture across Core and Node.
This commit is contained in:
@@ -2,7 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {build} from 'esbuild';
|
||||
const result=await build({entryPoints:[new URL('../src/core/fleet/roverInput.ts',import.meta.url).pathname],bundle:true,write:false,platform:'node',format:'esm'});
|
||||
const {keyDemand,roverSettings}=await import('data:text/javascript;base64,'+Buffer.from(result.outputFiles[0].contents).toString('base64'));
|
||||
const {keyDemand,roverSettings,roverNumberInput,persistableRoverSettings}=await import('data:text/javascript;base64,'+Buffer.from(result.outputFiles[0].contents).toString('base64'));
|
||||
const keys=(...k)=>new Set(k.map(v=>'Key'+v));
|
||||
test('arcade mixes directions and opposite keys cancel',()=>{
|
||||
assert.deepEqual(keyDemand('arcade',keys('W')),{left:1,right:1});
|
||||
@@ -21,3 +21,34 @@ test('invalid stored settings never grant motion or invalid limits',()=>{
|
||||
assert.equal(roverSettings({version:1,model:'https://other/model.glb'}).model,'');
|
||||
assert.deepEqual(keyDemand('arcade',new Set()),{left:0,right:0});
|
||||
});
|
||||
test('saved RPM never becomes full throttle during migration',()=>{
|
||||
const migrated=roverSettings({version:1,maxErpm:3000,currentA:30,mode:'tank',model:'dcd006-v020',throttlePercent:100});
|
||||
assert.equal(migrated.version,3);assert.equal(migrated.throttlePercent,10);
|
||||
assert.equal(migrated.mode,'tank');assert.equal(migrated.model,'dcd006-v020');
|
||||
assert.equal(roverSettings({...migrated,throttlePercent:50}).throttlePercent,50);
|
||||
assert.equal(roverSettings({...migrated,throttlePercent:Infinity}).throttlePercent,10);
|
||||
assert.equal(roverSettings({...migrated,throttlePercent:101}).throttlePercent,100);
|
||||
});
|
||||
|
||||
test('legacy empty and clamped current recover to 30 A once',()=>{
|
||||
for(const version of [1,2])for(const currentA of [0,.5,null,undefined,-1])
|
||||
assert.equal(roverSettings({version,currentA}).currentA,30);
|
||||
assert.equal(roverSettings({version:2,currentA:12,throttlePercent:70}).currentA,12);
|
||||
assert.equal(roverSettings({version:2,currentA:.5,throttlePercent:70}).throttlePercent,70);
|
||||
assert.equal(roverSettings({version:3,currentA:.5}).currentA,.5);
|
||||
});
|
||||
test('empty and invalid number drafts cannot overwrite saved valid settings',()=>{
|
||||
const saved=roverSettings({version:3,currentA:30,throttlePercent:70});
|
||||
assert.ok(persistableRoverSettings(saved));
|
||||
for(const text of ['', ' ', '0', 'Infinity', 'NaN'])
|
||||
assert.equal(persistableRoverSettings({...saved,currentA:roverNumberInput(text)}),false);
|
||||
assert.ok(Number.isNaN(roverNumberInput('')));
|
||||
assert.ok(persistableRoverSettings({...saved,currentA:roverNumberInput('0.5')}));
|
||||
});
|
||||
|
||||
test('operator current above 30 A persists without silently changing it',()=>{
|
||||
for(const currentA of [35,60,100,120,150]){
|
||||
const saved=roverSettings({version:3,currentA});assert.equal(saved.currentA,currentA);
|
||||
assert.ok(persistableRoverSettings(saved));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user