From f3807d265d52eb2eb32b58bed8eba8637676d8c5 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 11 Jul 2024 12:42:49 +0200 Subject: [PATCH] [#754] Add test --- .../4337/test/erc4337/Safe4337Module.spec.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/4337/test/erc4337/Safe4337Module.spec.ts b/modules/4337/test/erc4337/Safe4337Module.spec.ts index 744a4b63..09552679 100644 --- a/modules/4337/test/erc4337/Safe4337Module.spec.ts +++ b/modules/4337/test/erc4337/Safe4337Module.spec.ts @@ -302,6 +302,38 @@ describe('Safe4337Module', () => { expect(await safeFromEntryPoint.validateUserOp.staticCall(userOp, ethers.ZeroHash, 0)).to.eq(packedValidationData) }) + + it('should indicate failed validation data when dynamic position pointer is invalid', async () => { + const { user, safeModule, validator, entryPoint } = await setupTests() + + const validAfter = BigInt(ethers.hexlify(ethers.randomBytes(3))) + const validUntil = validAfter + BigInt(ethers.hexlify(ethers.randomBytes(3))) + + const safeOp = buildSafeUserOpTransaction( + await safeModule.getAddress(), + user.address, + 0, + '0x', + '0', + await entryPoint.getAddress(), + false, + false, + { + validAfter, + validUntil, + }, + ) + + const userOp = buildPackedUserOperationFromSafeUserOperation({ + safeOp, + signature: ethers.hexlify(ethers.randomBytes(32)) + '00'.padStart(64, '0') + '00' + ethers.hexlify(ethers.randomBytes(65)).slice(2), + }) + const packedValidationData = packValidationData(1, validUntil, validAfter) + const entryPointImpersonator = await ethers.getSigner(await entryPoint.getAddress()) + const safeFromEntryPoint = safeModule.connect(entryPointImpersonator) + + expect(await safeFromEntryPoint.validateUserOp.staticCall(userOp, ethers.ZeroHash, 0)).to.eq(packedValidationData) + }) }) describe('execUserOp', () => {