Last active
June 15, 2023 22:36
-
-
Save devtooligan/0be2b0c5148dabd26843d67091f50b04 to your computer and use it in GitHub Desktop.
Foundry test - Emit event and revert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.19; | |
import "forge-std/Test.sol"; | |
contract Reverter { | |
event Test(); | |
function emitAndRevert() external { | |
emit Test(); | |
revert(); | |
} | |
} | |
contract TestEmitRevert is Test { | |
event Test(); | |
Reverter reverter = new Reverter(); | |
function test_revertEvent() external { | |
vm.expectEmit(); | |
emit Test(); | |
address(reverter).call(abi.encodeWithSignature("emitAndRevert()")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment