Skip to content

Commit

Permalink
Merge pull request #126 from privacy-scaling-explorations/fix/update-…
Browse files Browse the repository at this point in the history
…index

fix(imt.sol): add correct indices in insert many function
  • Loading branch information
cedoor committed Jan 15, 2024
2 parents 53a80ba + bf19095 commit 320f5c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/imt.sol/contracts/internal/InternalLeanIMT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ library InternalLeanIMT {
revert LeafAlreadyExists();
}

self.leaves[leaves[i]] = self.size + i;
self.leaves[leaves[i]] = self.size + 1 + i;

unchecked {
++i;
Expand Down
9 changes: 9 additions & 0 deletions packages/imt.sol/test/LeanIMT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ describe("LeanIMT", () => {

expect(index).to.equal(0)
})
it("Should return the indices of the leaves", async () => {
await leanIMTTest.insertMany([1, 2])

const index1 = await leanIMTTest.indexOf(1)
const index2 = await leanIMTTest.indexOf(2)

expect(index1).to.equal(0)
expect(index2).to.equal(1)
})
})

describe("# root", () => {
Expand Down

0 comments on commit 320f5c9

Please sign in to comment.