Skip to content

Commit

Permalink
setPostOpCost tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaanshK committed Jul 4, 2024
1 parent 5da6fbe commit 199d312
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 81 deletions.
18 changes: 0 additions & 18 deletions contracts/test/Foo.sol

This file was deleted.

46 changes: 0 additions & 46 deletions contracts/test/Lock.sol

This file was deleted.

17 changes: 0 additions & 17 deletions scripts/foundry/Deploy.s.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.26;

import { console2 } from "forge-std/src/console2.sol";
import { NexusTestBase } from "../../base/NexusTestBase.sol";
import { IBiconomySponsorshipPaymaster } from "../../../../contracts/interfaces/IBiconomySponsorshipPaymaster.sol";
import { BiconomySponsorshipPaymaster } from "../../../../contracts/sponsorship/SponsorshipPaymasterWithPremium.sol";
Expand All @@ -25,13 +26,15 @@ contract TestSponsorshipPaymasterWithPremium is NexusTestBase {
assertEq(address(testArtifact.entryPoint()), ENTRYPOINT_ADDRESS);
assertEq(testArtifact.verifyingSigner(), PAYMASTER_SIGNER.addr);
assertEq(testArtifact.feeCollector(), PAYMASTER_FEE_COLLECTOR.addr);
assertEq(testArtifact.postopCost(), 0 wei);
}

function test_CheckInitialPaymasterState() external view {
assertEq(bicoPaymaster.owner(), PAYMASTER_OWNER.addr);
assertEq(address(bicoPaymaster.entryPoint()), ENTRYPOINT_ADDRESS);
assertEq(bicoPaymaster.verifyingSigner(), PAYMASTER_SIGNER.addr);
assertEq(bicoPaymaster.feeCollector(), PAYMASTER_FEE_COLLECTOR.addr);
assertEq(bicoPaymaster.postopCost(), 0 wei);
}

function test_OwnershipTransfer() external prankModifier(PAYMASTER_OWNER.addr) {
Expand Down Expand Up @@ -261,4 +264,26 @@ contract TestSponsorshipPaymasterWithPremium is NexusTestBase {
vm.expectRevert("withdraw failed");
bicoPaymaster.withdrawEth(payable(ALICE_ADDRESS), ethAmount);
}

function test_SetPostopCost() external prankModifier(PAYMASTER_OWNER.addr) {
uint48 initialPostopCost = bicoPaymaster.postopCost();
assertEq(initialPostopCost, 0 wei);
uint48 newPostopCost = initialPostopCost + 1 wei;

vm.expectEmit(true, true, false, true, address(bicoPaymaster));
emit IBiconomySponsorshipPaymaster.PostopCostChanged(initialPostopCost, newPostopCost);
bicoPaymaster.setPostopCost(newPostopCost);

uint48 resultingPostopCost = bicoPaymaster.postopCost();
assertEq(resultingPostopCost, newPostopCost);
}

function test_RevertIf_SetPostopCostToHigh() external prankModifier(PAYMASTER_OWNER.addr) {
uint48 initialPostopCost = bicoPaymaster.postopCost();
assertEq(initialPostopCost, 0 wei);
uint48 newPostopCost = initialPostopCost + 200_001 wei;

vm.expectRevert("Gas overhead too high");
bicoPaymaster.setPostopCost(newPostopCost);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,18 @@ contract TestFuzz_SponsorshipPaymasterWithPremium is NexusTestBase {
assertEq(ALICE_ADDRESS.balance, initialAliceBalance + ethAmount);
assertEq(address(bicoPaymaster).balance, 0 ether);
}

function testFuzz_SetPostopCost(uint48 value) external prankModifier(PAYMASTER_OWNER.addr) {
vm.assume(value <= 200_000 wei);
uint48 initialPostopCost = bicoPaymaster.postopCost();
assertEq(initialPostopCost, 0 wei);
uint48 newPostopCost = value;

vm.expectEmit(true, true, false, true, address(bicoPaymaster));
emit IBiconomySponsorshipPaymaster.PostopCostChanged(initialPostopCost, newPostopCost);
bicoPaymaster.setPostopCost(newPostopCost);

uint48 resultingPostopCost = bicoPaymaster.postopCost();
assertEq(resultingPostopCost, newPostopCost);
}
}

0 comments on commit 199d312

Please sign in to comment.