Fix BigInt serialization in GET /api/device (500 on real hardware) (#14)
CI / build + unit (push) Successful in 18s
CI / build + unit (push) Successful in 18s
This commit was merged in pull request #14.
This commit is contained in:
@@ -718,6 +718,32 @@ describe('MeshService device info', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('serializes proto uint64 fields as strings (JSON-safe)', async () => {
|
||||
const bridge = await startBridge();
|
||||
process.env.MESH_HOST = '127.0.0.1';
|
||||
process.env.MESH_PORT = String(bridge.port);
|
||||
const svc = new MeshService();
|
||||
try {
|
||||
svc.onModuleInit();
|
||||
await waitFor(
|
||||
() => bridge.sockets.length === 1 && svc.status().connected,
|
||||
);
|
||||
|
||||
// powermonEnables is a proto uint64 — protobuf-es decodes it as native bigint
|
||||
bridge.sockets[0].write(
|
||||
configSectionFrame('power', { powermonEnables: 123n }),
|
||||
);
|
||||
|
||||
await waitFor(() => svc.deviceInfo().localConfig.power !== undefined);
|
||||
const info = svc.deviceInfo();
|
||||
expect(info.localConfig.power?.powermonEnables).toBe('123'); // bigint -> decimal string
|
||||
expect(() => JSON.stringify(info)).not.toThrow(); // no "Do not know how to serialize a BigInt"
|
||||
} finally {
|
||||
svc.onModuleDestroy();
|
||||
bridge.close();
|
||||
}
|
||||
});
|
||||
|
||||
it('summarizes NodeInfo snr/hopsAway/viaMqtt when present', async () => {
|
||||
const bridge = await startBridge();
|
||||
process.env.MESH_HOST = '127.0.0.1';
|
||||
|
||||
Reference in New Issue
Block a user