a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: add dupe/canonical test

Mary 26c5c3df d6630e05

+16
+16
packages/utilities/cbor/lib/index.test.ts
··· 338 338 expect(() => encode(new Map([[1, 2]]))).toThrow(); 339 339 }); 340 340 341 + it('throws on non-canonically sorted map keys', () => { 342 + // manually craft CBOR with keys in wrong order: {"bb": 1, "a": 2} 343 + // map with 2 items (0xa2), "bb" (0x62 0x62 0x62), 1 (0x01), "a" (0x61 0x61), 2 (0x02) 344 + const malformedCbor = new Uint8Array([0xa2, 0x62, 0x62, 0x62, 0x01, 0x61, 0x61, 0x02]); 345 + 346 + expect(() => decode(malformedCbor)).toThrow('map keys are not in canonical order or contain duplicates'); 347 + }); 348 + 349 + it('throws on duplicate map keys', () => { 350 + // manually craft CBOR with duplicate keys: {"a": 1, "a": 2} 351 + // map with 2 items (0xa2), "a" (0x61 0x61), 1 (0x01), "a" (0x61 0x61), 2 (0x02) 352 + const malformedCbor = new Uint8Array([0xa2, 0x61, 0x61, 0x01, 0x61, 0x61, 0x02]); 353 + 354 + expect(() => decode(malformedCbor)).toThrow('map keys are not in canonical order or contain duplicates'); 355 + }); 356 + 341 357 function decodeCborMultiple(bytes: Uint8Array, expected: number): unknown[] { 342 358 const values: unknown[] = []; 343 359