-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathmap_slot.test.ts
25 lines (20 loc) · 951 Bytes
/
map_slot.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';
import { updateInlineTestData } from '@aztec/foundation/testing';
import { deriveStorageSlotInMap } from './index.js';
describe('Map slot', () => {
it('derived map slot matches Noir', () => {
const mapSlot = new Fr(0x132258fb6962c4387ba659d9556521102d227549a386d39f0b22d1890d59c2b5n);
const key = AztecAddress.fromString('0x302dbc2f9b50a73283d5fb2f35bc01eae8935615817a0b4219a057b2ba8a5a3f');
const slot = deriveStorageSlotInMap(mapSlot, key);
expect(slot.toString()).toMatchInlineSnapshot(
`"0x15b9fe39449affd8b377461263e9d2b610b9ad40580553500b4e41d9cbd887ac"`,
);
// Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data
updateInlineTestData(
'noir-projects/noir-protocol-circuits/crates/types/src/storage/map.nr',
'slot_from_typescript',
slot.toString(),
);
});
});