Skip to content

Commit 058cfc2

Browse files
test: todos
1 parent cab6763 commit 058cfc2

File tree

1 file changed

+69
-83
lines changed

1 file changed

+69
-83
lines changed

test/BasedAppManager.t.sol

Lines changed: 69 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -404,73 +404,6 @@ contract BasedAppManagerTest is Test, OwnableUpgradeable {
404404
vm.stopPrank();
405405
}
406406

407-
// ********************
408-
// ** Section: bApps **
409-
// ********************
410-
411-
function testRegisterService() public {
412-
vm.startPrank(USER1);
413-
address[] memory tokensInput = new address[](1);
414-
tokensInput[0] = address(erc20mock);
415-
uint32 sharedRiskLevelInput = 102;
416-
uint32 slashingCorrelationPenaltyInput = 100;
417-
proxiedManager.registerService(
418-
USER1, SERVICE1, tokensInput, sharedRiskLevelInput, slashingCorrelationPenaltyInput
419-
);
420-
(address owner, uint32 slashingCorrelationPenalty, uint32 sharedRiskLevel) = proxiedManager.services(SERVICE1);
421-
assertEq(owner, USER1, "Service owner");
422-
assertEq(sharedRiskLevelInput, sharedRiskLevel, "Service sharedRiskLevel");
423-
assertEq(slashingCorrelationPenaltyInput, slashingCorrelationPenalty, "Service slashingCorrelationPenalty");
424-
address[] memory tokens = proxiedManager.getServiceTokens(SERVICE1);
425-
assertEq(tokens[0], address(erc20mock), "Service token");
426-
assertEq(tokensInput[0], address(erc20mock), "Service token");
427-
vm.stopPrank();
428-
}
429-
430-
function testRegisterServiceTwice() public {
431-
vm.startPrank(USER1);
432-
address[] memory tokensInput = new address[](1);
433-
tokensInput[0] = address(erc20mock);
434-
uint32 sharedRiskLevelInput = 102;
435-
uint32 slashingCorrelationPenaltyInput = 100;
436-
proxiedManager.registerService(
437-
USER1, SERVICE1, tokensInput, sharedRiskLevelInput, slashingCorrelationPenaltyInput
438-
);
439-
(address owner, uint32 slashingCorrelationPenalty, uint32 sharedRiskLevel) = proxiedManager.services(SERVICE1);
440-
vm.expectRevert("Service already registered");
441-
proxiedManager.registerService(USER1, SERVICE1, tokensInput, 2, 2);
442-
assertEq(owner, USER1, "Service owner");
443-
assertEq(sharedRiskLevelInput, sharedRiskLevel, "Service sharedRiskLevel");
444-
assertEq(slashingCorrelationPenaltyInput, slashingCorrelationPenalty, "Service slashingCorrelationPenalty");
445-
address[] memory tokens = proxiedManager.getServiceTokens(SERVICE1);
446-
assertEq(tokens[0], address(erc20mock), "Service token");
447-
assertEq(tokensInput[0], address(erc20mock), "Service token");
448-
vm.stopPrank();
449-
}
450-
451-
function testRegisterServiceOverwrite() public {
452-
vm.startPrank(USER1);
453-
address[] memory tokensInput = new address[](1);
454-
tokensInput[0] = address(erc20mock);
455-
uint32 sharedRiskLevelInput = 102;
456-
uint32 slashingCorrelationPenaltyInput = 100;
457-
proxiedManager.registerService(
458-
USER1, SERVICE1, tokensInput, sharedRiskLevelInput, slashingCorrelationPenaltyInput
459-
);
460-
(address owner, uint32 slashingCorrelationPenalty, uint32 sharedRiskLevel) = proxiedManager.services(SERVICE1);
461-
assertEq(owner, USER1, "Service owner");
462-
assertEq(sharedRiskLevelInput, sharedRiskLevel, "Service sharedRiskLevel");
463-
assertEq(slashingCorrelationPenaltyInput, slashingCorrelationPenalty, "Service slashingCorrelationPenalty");
464-
address[] memory tokens = proxiedManager.getServiceTokens(SERVICE1);
465-
assertEq(tokens[0], address(erc20mock), "Service token");
466-
assertEq(tokensInput[0], address(erc20mock), "Service token");
467-
vm.stopPrank();
468-
vm.startPrank(ATTACKER);
469-
vm.expectRevert("Service already registered");
470-
proxiedManager.registerService(ATTACKER, SERVICE1, tokensInput, 2, 2);
471-
vm.stopPrank();
472-
}
473-
474407
function testStrategyOptInToService() public {
475408
testCreateStrategy();
476409
testRegisterService();
@@ -550,32 +483,85 @@ contract BasedAppManagerTest is Test, OwnableUpgradeable {
550483
vm.stopPrank();
551484
}
552485

553-
function testCreateObligationToNonExistingServiceRevert() public {
554-
vm.startPrank(USER1);
486+
function checkUserTotalAndObligationNumber() public {}
487+
function testRevertNotMatchTokensServiceAndStrategy() public {}
488+
function testRevertDepositNonSupportedTokensIntoStrategy() public {}
489+
function testRevertDepositNonSupportedETHIntoStrategy() public {}
490+
function testRevertObligationHigherThanMaxPercentage() public {}
491+
function testCreateObligationToNonExistingServiceRevert() public {}
492+
function testCreateObligationToNonExistingStrategyRevert() public {}
493+
function testCreateObligationToNotOwnedStrategyRevert() public {}
494+
function testWithdrawErc20FromStrategy() public {}
495+
function testWithdrawETHFromStrategy() public {}
496+
function testUpdateStrategy() public {}
497+
function testRevertObligationWithNonMatchingToken() public {}
498+
499+
// ********************
500+
// ** Section: bApps **
501+
// ********************
555502

503+
function testRegisterService() public {
504+
vm.startPrank(USER1);
505+
address[] memory tokensInput = new address[](1);
506+
tokensInput[0] = address(erc20mock);
507+
uint32 sharedRiskLevelInput = 102;
508+
uint32 slashingCorrelationPenaltyInput = 100;
509+
proxiedManager.registerService(
510+
USER1, SERVICE1, tokensInput, sharedRiskLevelInput, slashingCorrelationPenaltyInput
511+
);
512+
(address owner, uint32 slashingCorrelationPenalty, uint32 sharedRiskLevel) = proxiedManager.services(SERVICE1);
513+
assertEq(owner, USER1, "Service owner");
514+
assertEq(sharedRiskLevelInput, sharedRiskLevel, "Service sharedRiskLevel");
515+
assertEq(slashingCorrelationPenaltyInput, slashingCorrelationPenalty, "Service slashingCorrelationPenalty");
516+
address[] memory tokens = proxiedManager.getServiceTokens(SERVICE1);
517+
assertEq(tokens[0], address(erc20mock), "Service token");
518+
assertEq(tokensInput[0], address(erc20mock), "Service token");
556519
vm.stopPrank();
557520
}
558521

559-
function testCreateObligationToNonExistingStrategyRevert() public {
522+
function testRegisterServiceTwice() public {
560523
vm.startPrank(USER1);
561-
524+
address[] memory tokensInput = new address[](1);
525+
tokensInput[0] = address(erc20mock);
526+
uint32 sharedRiskLevelInput = 102;
527+
uint32 slashingCorrelationPenaltyInput = 100;
528+
proxiedManager.registerService(
529+
USER1, SERVICE1, tokensInput, sharedRiskLevelInput, slashingCorrelationPenaltyInput
530+
);
531+
(address owner, uint32 slashingCorrelationPenalty, uint32 sharedRiskLevel) = proxiedManager.services(SERVICE1);
532+
vm.expectRevert("Service already registered");
533+
proxiedManager.registerService(USER1, SERVICE1, tokensInput, 2, 2);
534+
assertEq(owner, USER1, "Service owner");
535+
assertEq(sharedRiskLevelInput, sharedRiskLevel, "Service sharedRiskLevel");
536+
assertEq(slashingCorrelationPenaltyInput, slashingCorrelationPenalty, "Service slashingCorrelationPenalty");
537+
address[] memory tokens = proxiedManager.getServiceTokens(SERVICE1);
538+
assertEq(tokens[0], address(erc20mock), "Service token");
539+
assertEq(tokensInput[0], address(erc20mock), "Service token");
562540
vm.stopPrank();
563541
}
564542

565-
function testCreateObligationToNotOwnedStrategyRevert() public {
543+
function testRegisterServiceOverwrite() public {
566544
vm.startPrank(USER1);
567-
545+
address[] memory tokensInput = new address[](1);
546+
tokensInput[0] = address(erc20mock);
547+
uint32 sharedRiskLevelInput = 102;
548+
uint32 slashingCorrelationPenaltyInput = 100;
549+
proxiedManager.registerService(
550+
USER1, SERVICE1, tokensInput, sharedRiskLevelInput, slashingCorrelationPenaltyInput
551+
);
552+
(address owner, uint32 slashingCorrelationPenalty, uint32 sharedRiskLevel) = proxiedManager.services(SERVICE1);
553+
assertEq(owner, USER1, "Service owner");
554+
assertEq(sharedRiskLevelInput, sharedRiskLevel, "Service sharedRiskLevel");
555+
assertEq(slashingCorrelationPenaltyInput, slashingCorrelationPenalty, "Service slashingCorrelationPenalty");
556+
address[] memory tokens = proxiedManager.getServiceTokens(SERVICE1);
557+
assertEq(tokens[0], address(erc20mock), "Service token");
558+
assertEq(tokensInput[0], address(erc20mock), "Service token");
559+
vm.stopPrank();
560+
vm.startPrank(ATTACKER);
561+
vm.expectRevert("Service already registered");
562+
proxiedManager.registerService(ATTACKER, SERVICE1, tokensInput, 2, 2);
568563
vm.stopPrank();
569564
}
570565

571-
// TODO: check user tokens and number of obligations
572-
573-
// TODO: test strategy tokens not match even one in service - should revert
574-
// TODO: try allocate more percentage than 100%% in obligations
575-
// TODO: try to allocate more NS percentage than 100%
576-
// TODO: try to deposit not supported erc20s
577-
// TODO: withdraw from strategy
578-
// TODO: update Strategy
579-
// TODO: update Service
580-
// TODO: test when adding a new obligation and match fail that the obligation is not added
566+
function testUpdateService() public {}
581567
}

0 commit comments

Comments
 (0)