app

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

resume-routing.test.ts (1112B)


      1 import { describe, expect, it } from 'vitest';
      2 import {
      3   approvePrivateResumeRouting,
      4   privateResumeRoutingSnapshot,
      5   type PrivateResumeRouting
      6 } from '../../src/lib/messaging/resume-routing.ts';
      7 describe('private route review is an opaque explicit local operation', () => {
      8   it('a forged route review cannot expose a peer or destination', () => {
      9     expect(
     10       privateResumeRoutingSnapshot({} as PrivateResumeRouting)
     11     ).toBeUndefined();
     12   });
     13   it('a forged reviewed token cannot mutate custody or publish', async () => {
     14     expect(
     15       await approvePrivateResumeRouting(
     16         {} as PrivateResumeRouting,
     17         'reviewed_private_destination_update'
     18       )
     19     ).toEqual({ status: 'invalid' });
     20   });
     21   it('caller objects never coerce into consent or a route review', async () => {
     22     let called = 0;
     23     const value = {
     24       toString() {
     25         called++;
     26         return 'reviewed_private_destination_update';
     27       }
     28     };
     29     expect(
     30       await approvePrivateResumeRouting({} as PrivateResumeRouting, value)
     31     ).toEqual({ status: 'invalid' });
     32     expect(called).toBe(0);
     33   });
     34 });