From 012a726933961353e2350aae97ea7c78919054ee Mon Sep 17 00:00:00 2001 From: livingrockrises <90545960+livingrockrises@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:09:36 +0400 Subject: [PATCH] refactor --- test/base/TestBase.sol | 10 ++++------ test/unit/concrete/TestSponsorshipPaymaster.t.sol | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/test/base/TestBase.sol b/test/base/TestBase.sol index 0390d72..e2cfaa8 100644 --- a/test/base/TestBase.sol +++ b/test/base/TestBase.sol @@ -198,7 +198,7 @@ abstract contract TestBase is CheatCodes, TestHelper, BaseEventsAndErrors { returns (bytes memory finalPmData, bytes memory signature) { // Initial paymaster data with zero signature - bytes memory initialPmData = abi.encodePacked( + userOp.paymasterAndData = abi.encodePacked( address(paymaster), pmData.validationGasLimit, pmData.postOpGasLimit, @@ -208,17 +208,15 @@ abstract contract TestBase is CheatCodes, TestHelper, BaseEventsAndErrors { pmData.priceMarkup, new bytes(65) // Zero signature ); - - // Update user operation with initial paymaster data - userOp.paymasterAndData = initialPmData; - + + { // Generate hash to be signed bytes32 paymasterHash = paymaster.getHash(userOp, pmData.paymasterId, pmData.validUntil, pmData.validAfter, pmData.priceMarkup); // Sign the hash signature = signMessage(signer, paymasterHash); - require(signature.length == 65, "Invalid Paymaster Signature length"); + } // Final paymaster data with the actual signature finalPmData = abi.encodePacked( diff --git a/test/unit/concrete/TestSponsorshipPaymaster.t.sol b/test/unit/concrete/TestSponsorshipPaymaster.t.sol index 8fd986e..2e0843a 100644 --- a/test/unit/concrete/TestSponsorshipPaymaster.t.sol +++ b/test/unit/concrete/TestSponsorshipPaymaster.t.sol @@ -209,12 +209,12 @@ contract TestSponsorshipPaymasterWithPriceMarkup is TestBase { bicoPaymaster.depositFor{ value: 10 ether }(DAPP_ACCOUNT.addr); startPrank(PAYMASTER_OWNER.addr); - bicoPaymaster.setUnaccountedGas(9e3); + bicoPaymaster.setUnaccountedGas(1e4); stopPrank(); PackedUserOperation[] memory ops = new PackedUserOperation[](1); // price markup of 1e6 - (PackedUserOperation memory userOp, bytes32 userOpHash) = createUserOp(ALICE, bicoPaymaster, 1e6, 10_000); + (PackedUserOperation memory userOp, bytes32 userOpHash) = createUserOp(ALICE, bicoPaymaster, 1e6, 15_000); ops[0] = userOp; uint256 initialBundlerBalance = BUNDLER.addr.balance; @@ -244,12 +244,12 @@ contract TestSponsorshipPaymasterWithPriceMarkup is TestBase { bicoPaymaster.depositFor{ value: 10 ether }(DAPP_ACCOUNT.addr); startPrank(PAYMASTER_OWNER.addr); - bicoPaymaster.setUnaccountedGas(25_000); + bicoPaymaster.setUnaccountedGas(27_000); stopPrank(); // 10% priceMarkup on gas cost PackedUserOperation[] memory ops = new PackedUserOperation[](1); - (PackedUserOperation memory userOp, bytes32 userOpHash) = createUserOp(ALICE, bicoPaymaster, 1_100_000, 35_000); + (PackedUserOperation memory userOp, bytes32 userOpHash) = createUserOp(ALICE, bicoPaymaster, 1_100_000, 40_000); ops[0] = userOp; uint256 initialBundlerBalance = BUNDLER.addr.balance;