import {createHash} from 'node:crypto'; import {writeFileSync} from 'node:fs'; import {join} from 'node:path'; const root = process.cwd(); const rows = [ {slot: 1, generation: 1, parentSlot: 0, parentGeneration: 0, state: 1, elapsedTicks: 100}, {slot: 2, generation: 7, parentSlot: 1, parentGeneration: 1, state: 2, elapsedTicks: 90}, {slot: 3, generation: 2, parentSlot: 2, parentGeneration: 7, state: 0, elapsedTicks: 10}, ]; const bytes = Buffer.alloc(144); bytes.write('TKPSV1\0\0', 0, 8, 'binary'); bytes.writeBigUInt64LE(9n, 8); bytes.writeBigUInt64LE(10n, 16); bytes.writeBigUInt64LE(100n, 24); bytes.writeBigUInt64LE(115n, 32); bytes.writeUInt32LE(rows.length, 40); rows.forEach((row, index) => { const at = 48 + index * 32; bytes.writeUInt32LE(row.slot, at); bytes.writeUInt32LE(row.generation, at + 4); bytes.writeUInt32LE(row.parentSlot, at + 8); bytes.writeUInt32LE(row.parentGeneration, at + 12); bytes.writeUInt32LE(row.state, at + 16); bytes.writeBigUInt64LE(BigInt(row.elapsedTicks), at + 24); }); const sha256 = createHash('sha256').update(bytes).digest('hex'); const directory = join(root, 'userspace/tests/fixtures'); writeFileSync(join(directory, 'core-tools-process.bin'), bytes); writeFileSync(join(directory, 'core-tools-process.json'), JSON.stringify({schema: 'turkos-k1300-process-view-fixture/v1', bytes: bytes.length, sha256, bootId: 9, frequency: 10, uptimeTicks: [100, 115], rows, deniedAddress: '0xffff000000001000'}, null, 2) + '\n'); console.log(JSON.stringify({status: 'K1300_PROCESS_FIXTURE_WRITTEN', sha256}));