-
Notifications
You must be signed in to change notification settings - Fork 453
support native eth in integration tests #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
39c5553
24090ff
5c1f4d6
3eba0cc
61943fb
fd6986b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,8 @@ import "src/contracts/permissions/PauserRegistry.sol"; | |
|
|
||
| import "src/test/mocks/EmptyContract.sol"; | ||
| import "src/test/mocks/ETHDepositMock.sol"; | ||
| import "src/test/mocks/BeaconChainOracleMock.sol"; | ||
| import "src/test/integration/mocks/BeaconChainOracleMock.t.sol"; | ||
| import "src/test/integration/mocks/BeaconChainMock.t.sol"; | ||
|
|
||
| import "src/test/integration/User.t.sol"; | ||
|
|
||
|
|
@@ -54,6 +55,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { | |
| // Mock Contracts to deploy | ||
| ETHPOSDepositMock ethPOSDeposit; | ||
| BeaconChainOracleMock beaconChainOracle; | ||
| BeaconChainMock public beaconChain; | ||
|
|
||
| // ProxyAdmin | ||
| ProxyAdmin eigenLayerProxyAdmin; | ||
|
|
@@ -253,7 +255,12 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { | |
| ethStrats.push(BEACONCHAIN_ETH_STRAT); | ||
| mixedStrats.push(BEACONCHAIN_ETH_STRAT); | ||
|
|
||
| // Create time machine and set block timestamp forward so we can create EigenPod proofs in the past | ||
| timeMachine = new TimeMachine(); | ||
| timeMachine.setProofGenStartTime(2 hours); | ||
|
|
||
| // Create mock beacon chain / proof gen interface | ||
| beaconChain = new BeaconChainMock(timeMachine, beaconChainOracle); | ||
| } | ||
|
|
||
| /// @dev Deploy a strategy and its underlying token, push to global lists of tokens/strategies, and whitelist | ||
|
|
@@ -332,7 +339,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { | |
| // User will use `delegateToBySignature` and `depositIntoStrategyWithSignature` | ||
| user = User(new User_SignedMethods()); | ||
| } else { | ||
| revert("_newUser: unimplemented userType"); | ||
| revert("_randUser: unimplemented userType"); | ||
| } | ||
|
|
||
| // For the specific asset selection we made, get a random assortment of | ||
|
|
@@ -378,14 +385,20 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { | |
| tokenBalances[i] = balance; | ||
| strategies[i] = strat; | ||
| } | ||
|
|
||
| return (strategies, tokenBalances); | ||
| } else if (assetType == HOLDS_ETH) { | ||
| revert("_getRandAssets: HOLDS_ETH unimplemented"); | ||
| strategies = new IStrategy[](1); | ||
| tokenBalances = new uint[](1); | ||
|
|
||
| // Award the user 32 ETH | ||
| uint amount = 32 ether; | ||
|
||
| cheats.deal(address(user), amount); | ||
|
|
||
| strategies[0] = BEACONCHAIN_ETH_STRAT; | ||
| tokenBalances[0] = amount; | ||
| } else if (assetType == HOLDS_MIX) { | ||
| revert("_getRandAssets: HOLDS_MIX unimplemented"); | ||
| revert("_dealRandAssets: HOLDS_MIX unimplemented"); | ||
| } else { | ||
| revert("_getRandAssets: assetType unimplemented"); | ||
| revert("_dealRandAssets: assetType unimplemented"); | ||
| } | ||
|
|
||
| return (strategies, tokenBalances); | ||
|
|
@@ -467,10 +480,16 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { | |
|
|
||
| for (uint i = 0; i < strategies.length; i++) { | ||
| IStrategy strat = strategies[i]; | ||
| IERC20 underlyingToken = strat.underlyingToken(); | ||
|
|
||
| emit log_named_string("token name: ", IERC20Metadata(address(underlyingToken)).name()); | ||
| emit log_named_uint("token balance: ", tokenBalances[i]); | ||
| if (strat == BEACONCHAIN_ETH_STRAT) { | ||
| emit log_named_string("token name: ", "Native ETH"); | ||
| emit log_named_uint("token balance: ", tokenBalances[i]); | ||
| } else { | ||
| IERC20 underlyingToken = strat.underlyingToken(); | ||
|
|
||
| emit log_named_string("token name: ", IERC20Metadata(address(underlyingToken)).name()); | ||
| emit log_named_uint("token balance: ", tokenBalances[i]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to answer the question asked in the TODO here:
I think this is OK as-is.
We should make sure we have some coverage for users having negative shares, but it is a bit of an "edge case", so I feel alright with it requiring a bit more special handling, and non-negative shares being the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other option is probably making every share amount an int256 and then casting back to uint256 as necessary, but that just sounds like wayyyy more of a pain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thoughts.
Agreed that non-negative is a good default, since we should only see negative shares if we do a balance update after a withdrawal -- and IMO that deserves its own top-level test.
If/when we write that test we can write a balance handler that specifically allows negative balances. In the meantime, if we hit negative here failing is fine because that shouldn't happen.