From 4c5ceca07673e89b112e849c2689ea0b1c3bf4d9 Mon Sep 17 00:00:00 2001 From: Vivian Plasencia Date: Tue, 26 Mar 2024 21:34:32 +0100 Subject: [PATCH] test(imt.sol): add test for the hash function in the LeanIMT Add a test for the has function in the LeanIMT to check that after deleting a leaf, the has function returns false for leaf 0. re #228 --- packages/imt.sol/test/LeanIMT.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/imt.sol/test/LeanIMT.ts b/packages/imt.sol/test/LeanIMT.ts index 3c36e7a19..034d4e34d 100644 --- a/packages/imt.sol/test/LeanIMT.ts +++ b/packages/imt.sol/test/LeanIMT.ts @@ -322,6 +322,21 @@ describe("LeanIMT", () => { expect(hasLeaf).to.equal(false) }) + + it("Should return false if the leaf is 0", async () => { + await leanIMTTest.insertMany([1, 2]) + jsLeanIMT.insertMany([BigInt(1), BigInt(2)]) + + jsLeanIMT.update(1, BigInt(0)) + + const { siblings } = jsLeanIMT.generateProof(1) + + await leanIMTTest.remove(2, siblings) + + const hasLeaf = await leanIMTTest.has(0) + + expect(hasLeaf).to.equal(false) + }) }) describe("# indexOf", () => { it("Should return the index of a leaf", async () => {