The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hyperlane-monorepo/solidity/test/PausableReentrancyGuard.t.sol

63 lines
1.4 KiB

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import {PausableReentrancyGuardUpgradeable} from "../contracts/PausableReentrancyGuard.sol";
contract MockPausableReentrancyGuard is PausableReentrancyGuardUpgradeable {
constructor() initializer {
__PausableReentrancyGuard_init();
}
function pause() external {
_pause();
}
function unpause() external {
_unpause();
}
function isPaused() external view returns (bool) {
return _isPaused();
}
function f1() public nonReentrantAndNotPaused {}
function f2() external nonReentrantAndNotPaused {
f1();
}
function f3() external notPaused {}
function f4() external nonReentrantAndNotPaused {}
}
contract PausableReentrancyGuardTest is Test {
MockPausableReentrancyGuard mprg;
function setUp() public {
mprg = new MockPausableReentrancyGuard();
}
function testPause() public {
mprg.f3();
mprg.pause();
vm.expectRevert("paused");
mprg.f3();
mprg.unpause();
mprg.f3();
}
function testNonreentrant() public {
mprg.f1();
vm.expectRevert("reentrant call (or paused)");
mprg.f2();
}
function testNonreentrantNotPaused() public {
mprg.pause();
vm.expectRevert("reentrant call (or paused)");
mprg.f1();
}
}