1import { describe, expect, it } from 'vitest';2import { gzipJson, gunzipJson, looksLikeStoredMetrics } from '../src/simrun';34describe('sim metrics storage helpers', () => {5 it('gzip/gunzip round-trips JSON', async () => {6 const value = { frames: [{ tick: 10, tribes: [] }], result: { tribes: [] }, stateHash: 'ab' };7 const gz = await gzipJson(value);8 expect(gz.byteLength).toBeGreaterThan(0);9 expect(await gunzipJson(gz)).toEqual(value);10 });1112 it('shape check accepts a plausible payload and rejects junk', () => {13 expect(14 looksLikeStoredMetrics({ frames: [], result: { tribes: [] }, stateHash: 'x' }),15 ).toBe(true);16 expect(looksLikeStoredMetrics(null)).toBe(false);17 expect(looksLikeStoredMetrics({ frames: 'no', result: { tribes: [] }, stateHash: 'x' })).toBe(false);18 expect(looksLikeStoredMetrics({ frames: [], result: null, stateHash: 'x' })).toBe(false);19 // over the frame-count bound (10k ticks / 10 + 1)20 expect(21 looksLikeStoredMetrics({ frames: new Array(1002).fill(0), result: { tribes: [] }, stateHash: 'x' }),22 ).toBe(false);23 });24});