Skip to content

Commit c99a5d6

Browse files
committed
test revert second initialize
1 parent 2830d60 commit c99a5d6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/HookSwaps.t.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,25 @@ contract HookSwapsTest is EulerSwapTestBase {
155155
vm.stopPrank();
156156
}
157157

158+
/// @dev initializing a new pool on an existing eulerswap instance will revert
159+
function test_revertSubsequentInitialize() public {
160+
PoolKey memory poolKey = eulerSwap.poolKey();
161+
PoolKey memory newPoolKey = eulerSwap.poolKey();
162+
newPoolKey.currency0 = CurrencyLibrary.ADDRESS_ZERO;
163+
164+
// hook intentionally reverts to prevent subsequent initializations
165+
vm.expectRevert(
166+
abi.encodeWithSelector(
167+
CustomRevert.WrappedError.selector,
168+
address(eulerSwap),
169+
IHooks.beforeInitialize.selector,
170+
abi.encodeWithSelector(UniswapHook.AlreadyInitialized.selector),
171+
abi.encodeWithSelector(Hooks.HookCallFailed.selector)
172+
)
173+
);
174+
poolManager.initialize(newPoolKey, 79228162514264337593543950336);
175+
}
176+
158177
function _swap(PoolKey memory key, bool zeroForOne, bool exactInput, uint256 amount) internal {
159178
IPoolManager.SwapParams memory swapParams = IPoolManager.SwapParams({
160179
zeroForOne: zeroForOne,

0 commit comments

Comments
 (0)