Skip to content

Commit

Permalink
[#754] Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Jul 11, 2024
1 parent 1091977 commit f3807d2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions modules/4337/test/erc4337/Safe4337Module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check failure on line 307 in modules/4337/test/erc4337/Safe4337Module.spec.ts

View workflow job for this annotation

GitHub Actions / lint

'validator' is assigned a value but never used

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', () => {
Expand Down

0 comments on commit f3807d2

Please sign in to comment.