app

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

public-key.test.ts (704B)


      1 import { describe, expect, it } from 'vitest';
      2 import { canonicalPublicKey } from '../../src/lib/contracts/public-key';
      3 import oracle from './reference-oracle.json';
      4 
      5 describe('exact public Rust key admission', () => {
      6   for (const row of oracle.key_cases)
      7     it(row.pubkey, () => {
      8       expect(canonicalPublicKey(row.pubkey)).toBe(
      9         row.accepted ? row.pubkey : undefined
     10       );
     11     });
     12   it('rejects noncanonical and unbounded input', () => {
     13     const key = oracle.key_cases[0].pubkey;
     14     for (const value of [
     15       null,
     16       {},
     17       key.toUpperCase(),
     18       ` ${key}`,
     19       key + '0',
     20       'a'.repeat(10000)
     21     ])
     22       expect(canonicalPublicKey(value)).toBeUndefined();
     23   });
     24 });