Skip to content

Commit 5c94bda

Browse files
feat: check bApp registered during OptIn (#53)
1 parent 58dae6b commit 5c94bda

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/core/modules/StrategyManager.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ contract StrategyManager is ReentrancyGuardTransient, IStrategyManager {
182182

183183
ValidationLib.validateArrayLengths(tokens, obligationPercentages);
184184

185+
if (!s.registeredBApps[bApp]) {
186+
revert IBasedAppManager.BAppNotRegistered();
187+
}
188+
185189
// Check if a strategy exists for the given bApp.
186190
// It is not possible opt-in to the same bApp twice with the same strategy owner.
187191
if (s.accountBAppStrategy[msg.sender][bApp] != 0) {

test/modules/StrategyManager.t.sol

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity 0.8.29;
44
import { IERC20, BasedAppMock } from "@ssv/test/helpers/Setup.t.sol";
55
import { BasedAppsManagerTest } from "@ssv/test/modules/BasedAppsManager.t.sol";
66
import { IStrategyManager } from "@ssv/src/core/interfaces/IStrategyManager.sol";
7-
import { IStrategyManager } from "@ssv/src/core/interfaces/IStrategyManager.sol";
7+
import { IBasedAppManager } from "@ssv/src/core/interfaces/IBasedAppManager.sol";
88
import { UtilsTest } from "@ssv/test/helpers/Utils.t.sol";
99
import { ValidationLib } from "@ssv/src/core/libraries/ValidationLib.sol";
1010

@@ -1041,6 +1041,34 @@ contract StrategyManagerTest is UtilsTest, BasedAppsManagerTest {
10411041
vm.stopPrank();
10421042
}
10431043

1044+
function testRevertStrategyOptingInToNonExistingBApp(
1045+
uint32 percentage
1046+
) public {
1047+
vm.assume(
1048+
percentage > 0 && percentage <= proxiedManager.maxPercentage()
1049+
);
1050+
testCreateStrategies();
1051+
vm.startPrank(USER1);
1052+
address[] memory tokensInput = new address[](0);
1053+
uint32[] memory obligationPercentagesInput = new uint32[](0);
1054+
for (uint256 i = 0; i < bApps.length; i++) {
1055+
vm.expectRevert(
1056+
abi.encodeWithSelector(
1057+
IBasedAppManager.BAppNotRegistered.selector,
1058+
address(erc20mock2)
1059+
)
1060+
);
1061+
proxiedManager.optInToBApp(
1062+
STRATEGY1,
1063+
address(bApps[i]),
1064+
tokensInput,
1065+
obligationPercentagesInput,
1066+
abi.encodePacked("0x00")
1067+
);
1068+
}
1069+
vm.stopPrank();
1070+
}
1071+
10441072
function testStrategyOwnerDepositERC20WithNoObligation(
10451073
uint256 amount
10461074
) public {

0 commit comments

Comments
 (0)