Skip to content

Commit

Permalink
include set and get test
Browse files Browse the repository at this point in the history
  • Loading branch information
querolita committed Oct 31, 2024
1 parent 677ee2c commit 5fb42f8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib/provable/test/dynamic-array-unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ let List = ZkProgram({
bytes.getOption(new Field(0)).assertSome();
//assert(bytes.getOption(new Field(1)) === undefined);

// TODO: Error if accessing out-of-bounds index
// Error if getting out-of-bounds index
try {
bytes.get(new Field(1));
} catch (error) {
console.log('Cannot get out-of-bounds index');
}

// Error if setting out-of-bounds index
try {
bytes.set(new Field(1), new UInt8(3));
} catch (error) {
console.log('Cannot set out-of-bounds index');
}

// Growing capacity should work correctly
let longerArray = bytes.growCapacityTo(10);
Expand Down

0 comments on commit 5fb42f8

Please sign in to comment.