Skip to content

Instantly share code, notes, and snippets.

@devtooligan
Last active June 15, 2023 22:36
Show Gist options
  • Save devtooligan/0be2b0c5148dabd26843d67091f50b04 to your computer and use it in GitHub Desktop.
Save devtooligan/0be2b0c5148dabd26843d67091f50b04 to your computer and use it in GitHub Desktop.
Foundry test - Emit event and revert
// 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