Skip to content

Commit b63d354

Browse files
committed
Expand BaseStrategyUpgradeable coverage
1 parent 54ab9d1 commit b63d354

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pkg/contracts/test/BaseStrategyUpgradeable.t.sol

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ contract BaseStrategyUpgradeableHarness is BaseStrategyUpgradeable {
8080

8181
contract BaseStrategyUpgradeableTest is Test {
8282
event PoolActive(bool active);
83+
event Initialized(uint256 poolId, bytes data);
8384

8485
BaseStrategyUpgradeableHarness internal strategy;
8586
MockAllo internal allo;
@@ -146,6 +147,37 @@ contract BaseStrategyUpgradeableTest is Test {
146147
strategy.exposedCheckOnlyPoolManager(manager);
147148
}
148149

150+
function test_initialize_requiresAllo() public {
151+
vm.expectRevert(abi.encodeWithSelector(Errors.UNAUTHORIZED.selector));
152+
strategy.initialize(5, "");
153+
}
154+
155+
function test_initialize_setsPoolIdAndEmits() public {
156+
bytes memory data = bytes("hello");
157+
vm.expectEmit(true, true, true, true, address(strategy));
158+
emit Initialized(9, data);
159+
160+
vm.prank(address(allo));
161+
strategy.initialize(9, data);
162+
163+
assertEq(strategy.getPoolId(), 9);
164+
}
165+
166+
function test_initialize_revertsIfAlreadyInitialized() public {
167+
vm.prank(address(allo));
168+
strategy.initialize(4, "");
169+
170+
vm.prank(address(allo));
171+
vm.expectRevert(abi.encodeWithSelector(Errors.ALREADY_INITIALIZED.selector));
172+
strategy.initialize(6, "");
173+
}
174+
175+
function test_initialize_revertsIfPoolIdZero() public {
176+
vm.prank(address(allo));
177+
vm.expectRevert(abi.encodeWithSelector(Errors.INVALID.selector));
178+
strategy.initialize(0, "");
179+
}
180+
149181
function test_poolActiveStateAndGuards() public {
150182
vm.expectRevert(abi.encodeWithSelector(Errors.POOL_INACTIVE.selector));
151183
strategy.exposedCheckOnlyActivePool();

0 commit comments

Comments
 (0)