Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Oct 15, 2024
1 parent 500c631 commit 012a726
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions test/base/TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions test/unit/concrete/TestSponsorshipPaymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 012a726

Please sign in to comment.