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:
@@ -0,0 +1,27 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {build} from 'esbuild';
|
||||
const built=await build({entryPoints:[new URL('../src/core/fleet/roverObservation.ts',import.meta.url).pathname],bundle:true,write:false,platform:'node',format:'esm'});
|
||||
const {roverObservationStatus:status}=await import('data:text/javascript;base64,'+Buffer.from(built.outputFiles[0].contents).toString('base64'));
|
||||
const empty={fresh:false,controlling:false,snapshot:{}};
|
||||
const board={fresh:true,controlling:false,snapshot:{supported:true,state:'observing',devices:[],profile:{bindings:{left:{device_id:'motor',uuid:'abc'}}}}};
|
||||
const initializing={...board,snapshot:{...board.snapshot,observation:{initializing_devices:['motor']}}};
|
||||
test('connecting to Core is different from receiving no fresh board telemetry',()=>{
|
||||
assert.equal(status(empty,'connecting').label,'Подключение к Mission Core');
|
||||
assert.equal(status(empty,'reconnecting').label,'Восстановление связи с Mission Core');
|
||||
assert.equal(status(empty,'connected').label,'Ожидание телеметрии с борта');
|
||||
assert.equal(status(empty,'connected').pulse,true);
|
||||
});
|
||||
test('initialization requires a fresh explicit driver phase for every missing VESC',()=>{
|
||||
assert.deepEqual(status(initializing,'connected'),{label:'Инициализация VESC',pulse:true});
|
||||
for(const value of [board,{...initializing,fresh:false},{...board,snapshot:{...board.snapshot,observation:{initializing_devices:['other']}}}]){
|
||||
assert.notEqual(status(value,'connected').label,'Инициализация VESC');
|
||||
}
|
||||
});
|
||||
test('ready readings end initialization; stale readings and actual faults cannot inherit it',()=>{
|
||||
const ready={...board,snapshot:{...board.snapshot,devices:[{id:'motor',uuid:'abc',age_ms:0}]}};
|
||||
assert.deepEqual(status(ready,'connected'),{label:null,pulse:false});
|
||||
assert.equal(status({...ready,snapshot:{...ready.snapshot,devices:[{id:'motor',uuid:'abc',age_ms:1000}]}},'connected').label,'Ожидание свежих показаний VESC');
|
||||
assert.deepEqual(status({...board,snapshot:{...board.snapshot,state:'fault',message:'Hardware failure'}},'connected'),{label:null,pulse:false});
|
||||
assert.equal(status({...board,snapshot:{}},'connected').pulse,false);
|
||||
});
|
||||
Reference in New Issue
Block a user