From 7fc5527464c46f5f013be05530f39103b36ebfd4 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Mon, 5 Aug 2024 13:15:36 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/MarginPaymaster.t.sol | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/MarginPaymaster.t.sol b/test/MarginPaymaster.t.sol index 56b0786..49629cb 100644 --- a/test/MarginPaymaster.t.sol +++ b/test/MarginPaymaster.t.sol @@ -14,6 +14,13 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {console} from "forge-std/console.sol"; contract MarginPaymasterTest is Bootstrap { + /*////////////////////////////////////////////////////////////// + EVENTS + //////////////////////////////////////////////////////////////*/ + + event PercentageMarkupSet(uint256); + event AuthorizerSet(address, bool); + /*////////////////////////////////////////////////////////////// STATE //////////////////////////////////////////////////////////////*/ @@ -129,6 +136,12 @@ contract MarginPaymasterTest is Bootstrap { assertFalse(marginPaymaster.authorizers(authorizer)); } + function testSetAuthorizerEvent(address authorizer, bool status) public { + vm.expectEmit(true, true, true, true); + emit AuthorizerSet(authorizer, status); + marginPaymaster.setAuthorizer(authorizer, status); + } + function testSetAuthorizerOnlyOwner() public { address authorizer = address(0x123456); bool status = true; @@ -361,6 +374,12 @@ contract MarginPaymasterTest is Bootstrap { assertEq(marginPaymaster.percentageMarkup(), newPercentageMarkup); } + function testSetPercentageMarkup(uint256 markup) public { + vm.expectEmit(true, true, true, true); + emit PercentageMarkupSet(markup); + marginPaymaster.setPercentageMarkup(markup); + } + function testSetPercentageMarkup_onlyOwner() public { uint256 newPercentageMarkup = 150; // 150% // Attempt to set the percentage markup as a non-owner