Skip to content

Commit

Permalink
restore noIsolate, and test_collectProtocolFees_locked_revertsWithPro…
Browse files Browse the repository at this point in the history
…tocolFeeCurrencySynced
  • Loading branch information
wjmelements committed Oct 24, 2024
1 parent 58b48fb commit b692606
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/PoolManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {AmountHelpers} from "./utils/AmountHelpers.sol";
import {ProtocolFeeLibrary} from "../src/libraries/ProtocolFeeLibrary.sol";
import {IProtocolFees} from "../src/interfaces/IProtocolFees.sol";
import {StateLibrary} from "../src/libraries/StateLibrary.sol";
import {TransientStateLibrary} from "../src/libraries/TransientStateLibrary.sol";
import {Actions} from "../src/test/ActionsRouter.sol";

contract PoolManagerTest is Test, Deployers {
Expand All @@ -38,6 +39,7 @@ contract PoolManagerTest is Test, Deployers {
using SafeCast for *;
using ProtocolFeeLibrary for uint24;
using StateLibrary for IPoolManager;
using TransientStateLibrary for IPoolManager;

event UnlockCallback();
event ProtocolFeeControllerUpdated(address feeController);
Expand Down Expand Up @@ -982,6 +984,15 @@ contract PoolManagerTest is Test, Deployers {
manager.burn(address(this), key.currency0.toId(), 1);
}

function test_collectProtocolFees_locked_revertsWithProtocolFeeCurrencySynced() public noIsolate {
manager.setProtocolFeeController(address(this));
// currency1 is never native
manager.sync(key.currency1);
assertEq(Currency.unwrap(key.currency1), Currency.unwrap(manager.getSyncedCurrency()));
vm.expectRevert(IProtocolFees.ProtocolFeeCurrencySynced.selector);
manager.collectProtocolFees(address(this), key.currency1, 1);
}

function test_collectProtocolFees_unlocked_revertsWithProtocolFeeCurrencySynced() public {
manager.setProtocolFeeController(address(actionsRouter));

Expand Down
9 changes: 9 additions & 0 deletions test/utils/Deployers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ contract Deployers is Test {
uint160 hookPermissionCount = 14;
uint160 clearAllHookPermissionsMask = ~uint160(0) << (hookPermissionCount);

modifier noIsolate() {
if (msg.sender != address(this)) {
(bool success,) = address(this).call(msg.data);
require(success);
} else {
_;
}
}

function deployFreshManager() internal virtual {
manager = new PoolManager();
}
Expand Down

0 comments on commit b692606

Please sign in to comment.