app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

message-interop.test.mjs (1474B)


      1 import assert from 'node:assert/strict';
      2 import test from 'node:test';
      3 import { createHash } from 'node:crypto';
      4 import { readFileSync } from 'node:fs';
      5 import { spawnSync } from 'node:child_process';
      6 const root = new URL('../../../contracts/interop/message/', import.meta.url);
      7 void test('Message fixture provenance binds five exact portable producer inputs', () => {
      8   const p = JSON.parse(
      9     readFileSync(new URL('provenance.v1.json', root), 'utf8')
     10   );
     11   assert.equal(p.revision, '189c49b74b4bafc142b00b76b296477931139e72');
     12   assert.equal(Object.keys(p.inputs).length, 5);
     13   for (const [name, hash] of Object.entries(p.inputs))
     14     assert.equal(
     15       createHash('sha256')
     16         .update(readFileSync(new URL(name, root)))
     17         .digest('hex'),
     18       hash,
     19       name
     20     );
     21   assert.match(p.qualification, /actual pinned Rust/);
     22   assert.ok(!JSON.stringify(p).includes('/Users/'));
     23 });
     24 void test('explicit Message interop runner rejects unapproved arguments before Cargo or generation', () => {
     25   const before = readFileSync(new URL('corpus.v1.json', root));
     26   const result = spawnSync(
     27     process.execPath,
     28     ['tools/check-message-interop.mjs', '--other'],
     29     {
     30       cwd: new URL('../../', import.meta.url),
     31       encoding: 'utf8',
     32       timeout: 86400000
     33     }
     34   );
     35   assert.equal(result.status, 1);
     36   assert.match(result.stderr, /expected no arguments or explicit --write/);
     37   assert.deepEqual(readFileSync(new URL('corpus.v1.json', root)), before);
     38 });