Skip to content

Commit

Permalink
fix broken test and sig verification logic
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Apr 7, 2024
1 parent e6d5769 commit a921986
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/sponsorship/SponsorshipPaymasterWithPremium.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ contract BiconomySponsorshipPaymaster is BasePaymaster, ReentrancyGuard, Biconom

bool validSig = verifyingSigner.isValidSignatureNow(
ECDSA_solady.toEthSignedMessageHash(getHash(userOp, paymasterId, validUntil, validAfter, priceMarkup)),
userOp.signature
signature
);

//don't revert on signature failure: return SIG_VALIDATION_FAILED
Expand Down
14 changes: 10 additions & 4 deletions test/hardhat/biconomy-sponsorship-paymaster-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ describe("EntryPoint with Biconomy Sponsorship Paymaster", function () {
await paymaster.depositFor(paymasterDepositorId, { value: parseEther("1") });

await entryPoint.depositTo(paymasterAddress, { value: parseEther("1") });

await deployer.sendTransaction({to: expected, value: parseEther("1"), data: '0x'});
});

describe("#validatePaymasterUserOp and #sendSponsoredTx", () => {
describe("Deployed Account : #validatePaymasterUserOp and #sendEmptySponsoredTx", () => {
it("succeed with valid signature", async () => {
const nonceKey = ethers.zeroPadBytes(await ecdsaModule.getAddress(), 24);
const userOp1 = await fillAndSign({
Expand All @@ -137,7 +139,8 @@ describe("EntryPoint with Biconomy Sponsorship Paymaster", function () {
ethers.zeroPadValue(toBeHex(MOCK_VALID_AFTER), 6),
ethers.zeroPadValue(toBeHex(MARKUP), 4),
'0x' + '00'.repeat(65)
])
]),
paymasterPostOpGasLimit: 40_000,
}, walletOwner, entryPoint, 'getNonce', nonceKey)
const hash = await paymaster.getHash(packUserOp(userOp1), paymasterDepositorId, MOCK_VALID_UNTIL, MOCK_VALID_AFTER, MARKUP)
const sig = await offchainSigner.signMessage(ethers.getBytes(hash))
Expand All @@ -150,16 +153,19 @@ describe("EntryPoint with Biconomy Sponsorship Paymaster", function () {
ethers.zeroPadValue(toBeHex(MOCK_VALID_AFTER), 6),
ethers.zeroPadValue(toBeHex(MARKUP), 4),
sig
])
]),
paymasterPostOpGasLimit: 40_000,
}, walletOwner, entryPoint, 'getNonce', nonceKey)
console.log("userOp: ", userOp);
// const parsedPnD = await paymaster.parsePaymasterAndData(userOp.paymasterAndData)
const res = await simulateValidation(userOp, await entryPoint.getAddress())
const validationData = parseValidationData(res.returnInfo.paymasterValidationData)
expect(validationData).to.eql({
aggregator: AddressZero,
validAfter: parseInt(MOCK_VALID_AFTER),
validUntil: parseInt(MOCK_VALID_UNTIL)
})

await entryPoint.handleOps([userOp], await deployer.getAddress())
});
});
})
Expand Down

0 comments on commit a921986

Please sign in to comment.