From 0ad7585f95309b5c9635991ac1651d2e4c0d0c9e Mon Sep 17 00:00:00 2001 From: aitbc Date: Wed, 29 Apr 2026 13:33:27 +0200 Subject: [PATCH] fix: use ethers.js event interface parsing for escrowId extraction - Replace direct topics[1] access with escrowService.interface.parseLog() - Use event.args[0] to extract escrowId from parsed event - Update all beforeEach hooks and time lock test to use proper event parsing - This fixes 'Escrow does not exist' errors caused by invalid escrowId extraction --- contracts/test/EscrowService.test.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/contracts/test/EscrowService.test.js b/contracts/test/EscrowService.test.js index 713ad8c6..7fddedae 100644 --- a/contracts/test/EscrowService.test.js +++ b/contracts/test/EscrowService.test.js @@ -95,7 +95,8 @@ describe("EscrowService", function () { ); const receipt = await tx.wait(); - const escrowId = ethers.getBigInt(receipt.logs[0].topics[1]); + const event = escrowService.interface.parseLog(receipt.logs[0]); + const escrowId = event.args[0]; expect(escrowId).to.not.be.undefined; }); @@ -156,7 +157,8 @@ describe("EscrowService", function () { "Test escrow" ); const receipt = await tx.wait(); - escrowId = ethers.getBigInt(receipt.logs[0].topics[1]); + const event = escrowService.interface.parseLog(receipt.logs[0]); + escrowId = event.args[0]; }); it("Should skip - fundEscrow not implemented", async function () { @@ -189,7 +191,8 @@ describe("EscrowService", function () { "Test escrow" ); const receipt = await tx.wait(); - escrowId = ethers.getBigInt(receipt.logs[0].topics[1]); + const event = escrowService.interface.parseLog(receipt.logs[0]); + escrowId = event.args[0]; }); it("Should release escrow to beneficiary", async function () { @@ -220,7 +223,8 @@ describe("EscrowService", function () { "Test escrow" ); const receipt = await tx.wait(); - const newEscrowId = ethers.getBigInt(receipt.logs[0].topics[1]); + const event = escrowService.interface.parseLog(receipt.logs[0]); + const newEscrowId = event.args[0]; await expect( escrowService.connect(depositor).releaseEscrow(newEscrowId, "Service completed") @@ -242,7 +246,8 @@ describe("EscrowService", function () { "Test escrow" ); const receipt = await tx.wait(); - escrowId = ethers.getBigInt(receipt.logs[0].topics[1]); + const event = escrowService.interface.parseLog(receipt.logs[0]); + escrowId = event.args[0]; }); it("Should refund escrow to depositor", async function () { @@ -309,7 +314,8 @@ describe("EscrowService", function () { "Test escrow" ); const receipt = await tx.wait(); - escrowId = ethers.getBigInt(receipt.logs[0].topics[1]); + const event = escrowService.interface.parseLog(receipt.logs[0]); + escrowId = event.args[0]; }); it("Should get escrow details", async function () {