-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from Layr-Labs/test/strategy-manager-cleanup
StrategyManager Unit Test Refactor
- Loading branch information
Showing
10 changed files
with
1,154 additions
and
819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
├── EigenPodManager Tree (*** denotes that integrationt tests are needed to validate path) | ||
├── when contract is deployed and initialized | ||
│ └── it should properly set storage | ||
├── when initialize called again | ||
│ └── it should revert | ||
├── when createPod called | ||
│ ├── given the user has already created a pod | ||
│ │ └── it should revert | ||
│ ├── given that the max number of pods has been deployed | ||
│ │ └── it should revert | ||
│ └── given the user has not created a pod | ||
│ └── it should deploy a pod | ||
├── when stake is called | ||
│ ├── given the user has not created a pod | ||
│ │ └── it should deploy a pod | ||
│ └── given the user has already created a pod | ||
│ └── it should call stake on the eigenPod | ||
├── when setMaxPods is called | ||
│ ├── given the user is not the pauser | ||
│ │ └── it should revert | ||
│ └── given the user is the pauser | ||
│ └── it should set the max pods | ||
├── when updateBeaconChainOracle is called | ||
│ ├── given the user is not the owner | ||
│ │ └── it should revert | ||
│ └── given the user is the owner | ||
│ └── it should set the beacon chain oracle | ||
├── when addShares is called | ||
│ ├── given that the caller is not the delegationManager | ||
│ │ └── it should revert | ||
│ ├── given that the podOwner address is 0 | ||
│ │ └── it should revert | ||
│ ├── given that the shares amount is negative | ||
│ │ └── it should revert | ||
│ ├── given that the shares is not a whole gwei amount | ||
│ │ └── it should revert | ||
│ └── given that all of the above conditions are satisfied | ||
│ └── it should update the podOwnerShares | ||
├── when removeShares is called | ||
│ ├── given that the caller is not the delegationManager | ||
│ │ └── it should revert | ||
│ ├── given that the shares amount is negative | ||
│ │ └── it should revert | ||
│ ├── given that the shares is not a whole gwei amount | ||
│ │ └── it should revert | ||
│ ├── given that removing shares results in the pod owner having negative shares | ||
│ │ └── it should revert | ||
│ └── given that all of the above conditions are satisfied | ||
│ └── it should update the podOwnerShares | ||
├── when withdrawSharesAsTokens is called | ||
│ ├── given that the podOwner is address 0 | ||
│ │ └── it should revert | ||
│ ├── given that the destination is address 0 | ||
│ │ └── it should revert | ||
│ ├── given that the shares amount is negative | ||
│ │ └── it should revert | ||
│ ├── given that the shares is not a whole gwei amount | ||
│ │ └── it should revert | ||
│ ├── given that the current podOwner shares are negative | ||
│ │ ├── given that the shares to withdraw are larger in magnitude than the shares of the podOwner | ||
│ │ │ └── it should set the podOwnerShares to 0 and decrement shares to withdraw by the share deficit | ||
│ │ └── given that the shares to withdraw are smaller in magnitude than shares of the podOwner | ||
│ │ └── it should increment the podOwner shares by the shares to withdraw | ||
│ └── given that the pod owner shares are positive | ||
│ └── it should withdraw restaked ETH from the eigenPod | ||
├── when shares are adjusted *** | ||
│ ├── given that sharesBefore is negative or 0 | ||
│ │ ├── given that sharesAfter is negative or zero | ||
│ │ │ └── the change in delegateable shares should be 0 | ||
│ │ └── given that sharesAfter is positive | ||
│ │ └── the change in delegateable shares should be positive | ||
│ └── given that sharesBefore is positive | ||
│ ├── given that sharesAfter is negative or zero | ||
│ │ └── the change in delegateable shares is negative sharesBefore | ||
│ └── given that sharesAfter is positive | ||
│ └── the change in delegateable shares is the difference between sharesAfter and sharesBefore | ||
└── when recordBeaconChainETHBalanceUpdate is called | ||
├── given that the podOwner's eigenPod is not the caller | ||
│ └── it should revert | ||
├── given that the podOwner is a zero address | ||
│ └── it should revert | ||
├── given that sharesDelta is not a whole gwei amount | ||
│ ├── it should revert | ||
│ └── given that the shares delta is valid | ||
│ └── it should update the podOwnerShares | ||
├── given that the change in delegateable shares is positive *** | ||
│ └── it should increase delegated shares on the delegationManager | ||
├── given that the change in delegateable shares is negative *** | ||
│ └── it should decrease delegated shares on the delegationManager | ||
├── given that the change in delegateable shares is 0 *** | ||
│ └── it should only update the podOwnerShares | ||
└── given that the function is reentered *** | ||
└── it should revert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
├── StrategyManagerUnit.t.sol (*** denotes that integration tests are needed to validate path) | ||
├── initialize | ||
| ├── given that initialized is only called once | ||
│ │ └── it should set the storage variables correctly (owner, strategyWhitelister, pauserRegistry) | ||
│ └── given that initialize is called again | ||
│ └── it should revert | ||
├── depositIntoStrategy() | ||
│ ├── given that deposits paused | ||
│ │ └── it should revert | ||
│ ├── given the function is re-entered | ||
│ │ └── it should revert | ||
│ ├── given that the strategy is not whitelisted | ||
│ │ └── it should revert | ||
│ ├── given the token safeTransferFrom() reverts | ||
│ │ └── it should revert | ||
│ └── given that token safeTransferFrom() succeeds | ||
│ ├── given the staker has existing shares in strategy (not first deposit) | ||
│ │ └── it should increase shares, nonce. while stakerStrategyListLength is unchanged | ||
│ ├── given the staker has no existing shares in strategy (first deposit) | ||
│ │ └── stakerStrategyListLength increases by 1 and shares increase | ||
│ ├── given the staker has delegated to a operator *** | ||
│ │ └── it should deposit successfully with shares increase, including delegated shares | ||
│ └── given the staker is not delegated | ||
│ └── it should deposit successfully with shares increase | ||
├── depositIntoStrategyWithSignature() | ||
│ ├── given that deposits paused | ||
│ │ └── it should revert | ||
│ ├── given the function is re-entered | ||
│ │ └── it should revert | ||
│ ├── given the signature expired | ||
│ │ └── it should revert | ||
│ ├── given that deposits paused and strategy not whitelisted | ||
│ │ └── it should revert | ||
│ ├── given the staker is a EOA | ||
│ │ ├── given the signature verification fails | ||
│ │ │ └── it should revert | ||
│ │ └── given the signature verification succeeds | ||
│ │ ├── given the token safeTransferFrom reverts | ||
│ │ │ └── it should revert | ||
│ │ └── given the token safeTransferFrom succeeds | ||
│ │ ├── given that the staker has delegated to a operator *** | ||
│ │ │ └── it should deposit successfully with shares and nonce increase, including delegated shares | ||
│ │ └── given that the staker is not delegated | ||
│ │ └── it should deposit successfully with shares and nonce increase | ||
│ └── given the staker is a contract | ||
│ ├── given the contract isn't EIP1271 compliant | ||
│ │ └── it should revert | ||
│ ├── given the signature verification fails, isValidSignature() return != EIP1271_MAGICVALUE | ||
│ │ └── it should revert | ||
│ └── given the signature verification succeeds, isValidSignature() returns EIP1271_MAGICVALUE | ||
│ ├── given the token safeTransferFrom reverts | ||
│ │ └── it should revert | ||
│ └── given the token safeTransferFrom succeeds | ||
│ ├── given the staker has delegated to a operator *** | ||
│ │ └── it should deposit successfully with shares and nonce increase, including delegated shares | ||
│ └── given the staker is not delegated | ||
│ └── it should deposit successfully with shares and nonce increase | ||
├── removeShares() | ||
│ ├── given not called by DelegationManager | ||
│ │ └── it should revert | ||
│ ├── given the share amount is 0 | ||
│ │ └── it should revert | ||
│ ├── given the share amount is too high, higher than deposited amount | ||
│ │ └── it should revert | ||
│ ├── given the share amount is equal to the deposited amount | ||
│ │ └── staker shares should be 0 with decremented stakerStrategyListLength | ||
│ └── given the share amount is less than the deposited amount | ||
│ └── staker shares should now be deposited - shares amount, unchanged stakerStrategyListLength | ||
├── addShares() | ||
│ ├── given not called by DelegationManager | ||
│ │ └── it should revert | ||
│ ├── given the share amount is 0 | ||
│ │ └── it should revert | ||
│ ├── given the staker is 0 address | ||
│ │ └── it should revert | ||
│ ├── given adding shares with 0 existing shares | ||
│ │ └── it should increase shares and increment stakerStrategyListLength | ||
│ ├── given adding shares with 0 existing shares and staker has MAX_STAKER_STRATEGY_LIST_LENGTH | ||
│ │ └── it should revert | ||
│ └── given the adding shares with > 0 existing shares | ||
│ └── it should increase shares, unchanged stakerStrategyListLength | ||
├── withdrawSharesAsTokens() | ||
│ ├── given not called by DelegationManager | ||
│ │ └── it should revert | ||
│ └── given that deposited strategy is called | ||
│ │ └── it should withdraw tokens from strategy with token balanceOf() update | ||
├── setStrategyWhitelister() | ||
│ ├── given not called by owner | ||
│ │ └── it should revert | ||
│ └── given called by owner address | ||
│ └── it should update strategyWhitelister address | ||
├── addStrategiesToDepositWhitelist() | ||
│ ├── given not called by strategyWhitelister address | ||
│ │ └── it should revert | ||
│ └── given the strategyWhitelister address is called | ||
│ ├── given adding one single strategy that is already whitelisted | ||
│ │ └── it should not emit StrategyAddedToDepositWhitelist with mapping still true | ||
│ ├── given adding one single strategy | ||
│ │ └── it should whitelist the new strategy with mapping set to true | ||
│ └── given adding multiple strategies to whitelist | ||
│ └── it should whitelist all new strategies with mappings set to true | ||
└── removeStrategiesFromDepositWhitelist() | ||
├── given not called by strategyWhitelister address | ||
│ └── it should revert | ||
└── given called by strategyWhitelister address | ||
├── given removing one single strategy that is not whitelisted | ||
│ └── it shouldn't emit StrategyRemovedFromDepositWhitelist with mapping still false | ||
├── given removing one single strategy | ||
│ └── it should de-whitelist the new strategy with mapping set to false | ||
└── given removing multiple strategies to whitelist | ||
└── it should de-whitelist all specified strategies with mappings set to false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.