Skip to content

Commit

Permalink
enable mapping test
Browse files Browse the repository at this point in the history
  • Loading branch information
querolita committed Oct 31, 2024
1 parent 4fb72f0 commit 677ee2c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/lib/provable/test/dynamic-array-unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ let List = ZkProgram({

// TODO: Error if accessing out-of-bounds index

// TODO: Mapping over elements should work correctly

/* bytes.push(new Field(1));
bytes.push(new Field(0));
let mapped = bytes.map(UInt8, (value) =>
Gadgets.add(value, new UInt8(1))
);
assert(mapped.get(new Field(0)).equals(new Field(3)));
assert(mapped.get(new Field(1)).equals(new Field(2)));
assert(mapped.get(new Field(2)).equals(new Field(1)));
*/

// Growing capacity should work correctly
let longerArray = bytes.growCapacityTo(10);
assert(longerArray.capacity === 10);
Expand All @@ -110,6 +98,16 @@ let List = ZkProgram({
let otherArray = bytes.growCapacityBy(2);
assert(otherArray.capacity === 10);
assert(otherArray.length.equals(new Field(1)));

// Mapping over elements should work correctly
bytes.push(new UInt8(1));
bytes.push(new UInt8(0));
let mapped = bytes.map(UInt8, (value) =>
UInt8.from(Gadgets.addMod32(value.value, UInt8.from(1).value))
);
assert(mapped.get(new Field(0)).value.equals(new Field(3)));
assert(mapped.get(new Field(1)).value.equals(new Field(2)));
assert(mapped.get(new Field(2)).value.equals(new Field(1)));
},
},
},
Expand Down

0 comments on commit 677ee2c

Please sign in to comment.