-
Notifications
You must be signed in to change notification settings - Fork 195
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
test: vaults fuzzing #918
base: feat/vaults
Are you sure you want to change the base?
test: vaults fuzzing #918
Changes from all commits
afc5fa1
e772d2a
0b6fc5c
6317957
c289fb8
d79df96
167c387
2386b48
79ecbbb
7fc5b7f
c9f78d0
166ef4b
c39aeea
7d05ee2
1203e29
6ae1888
ea08979
f7870a8
02ac654
490652e
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
// for testing purposes only | ||
|
||
pragma solidity 0.8.9; | ||
|
||
contract SecondOpinionOracle__Mock { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure that we need that mock. We can harness OracleReportSanityChecker and just return true on _askSecondOpinion. |
||
bool private success; | ||
uint256 private clBalanceGwei; | ||
uint256 private withdrawalVaultBalanceWei; | ||
uint256 private totalDepositedValidators; | ||
uint256 private totalExitedValidators; | ||
|
||
function getReport(uint256 refSlot) external view returns (bool, uint256, uint256, uint256, uint256) { | ||
return (success, clBalanceGwei, withdrawalVaultBalanceWei, totalDepositedValidators, totalExitedValidators); | ||
} | ||
|
||
function mock__setReportValues( | ||
bool _success, | ||
uint256 _clBalanceGwei, | ||
uint256 _withdrawalVaultBalanceWei, | ||
uint256 _totalDepositedValidators, | ||
uint256 _totalExitedValidators | ||
) external { | ||
success = _success; | ||
clBalanceGwei = _clBalanceGwei; | ||
withdrawalVaultBalanceWei = _withdrawalVaultBalanceWei; | ||
totalDepositedValidators = _totalDepositedValidators; | ||
totalExitedValidators = _totalExitedValidators; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,11 @@ | |
|
||
pragma solidity 0.8.9; | ||
|
||
import {StakingRouter} from "contracts/0.8.9/StakingRouter.sol"; | ||
|
||
contract StakingRouter__MockForLidoAccounting { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noticed that this file is being used in the accounting unit tests. It would be better to clone the file and rename it to StakingRouter__MockForLidoAccountingFuzzing to clarify its purpose. Separating the mocks will simplify mock management and ensure that they do not interfere with other tests. |
||
event Mock__MintedRewardsReported(); | ||
event Mock__MintedTotalShares(uint256 indexed _totalShares); | ||
|
||
address[] private recipients__mocked; | ||
uint256[] private stakingModuleIds__mocked; | ||
|
@@ -32,6 +35,13 @@ contract StakingRouter__MockForLidoAccounting { | |
|
||
function reportRewardsMinted(uint256[] calldata _stakingModuleIds, uint256[] calldata _totalShares) external { | ||
emit Mock__MintedRewardsReported(); | ||
|
||
uint256 totalShares = 0; | ||
for (uint256 i = 0; i < _totalShares.length; i++) { | ||
totalShares += _totalShares[i]; | ||
} | ||
|
||
emit Mock__MintedTotalShares(totalShares); | ||
} | ||
|
||
function mock__getStakingRewardsDistribution( | ||
|
@@ -47,4 +57,75 @@ contract StakingRouter__MockForLidoAccounting { | |
totalFee__mocked = _totalFee; | ||
precisionPoint__mocked = _precisionPoints; | ||
} | ||
|
||
function getStakingModuleIds() public view returns (uint256[] memory) { | ||
return stakingModuleIds__mocked; | ||
} | ||
|
||
function getRecipients() public view returns (address[] memory) { | ||
return recipients__mocked; | ||
} | ||
|
||
function getStakingModule(uint256 _stakingModuleId) public view returns (StakingRouter.StakingModule memory) { | ||
if (_stakingModuleId >= 4) { | ||
revert("Staking module does not exist"); | ||
} | ||
|
||
if (_stakingModuleId == 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment that production values are used? And if possible to add a proof link. Otherwise no one will guess why the numbers are like they are here. |
||
return | ||
StakingRouter.StakingModule({ | ||
id: 1, | ||
stakingModuleAddress: 0x55032650b14df07b85bF18A3a3eC8E0Af2e028d5, | ||
stakingModuleFee: 500, | ||
treasuryFee: 500, | ||
stakeShareLimit: 10000, | ||
status: 0, | ||
name: "curated-onchain-v1", | ||
lastDepositAt: 1732694279, | ||
lastDepositBlock: 21277744, | ||
exitedValidatorsCount: 88207, | ||
priorityExitShareThreshold: 10000, | ||
maxDepositsPerBlock: 150, | ||
minDepositBlockDistance: 25 | ||
}); | ||
} | ||
|
||
if (_stakingModuleId == 2) { | ||
return | ||
StakingRouter.StakingModule({ | ||
id: 2, | ||
stakingModuleAddress: 0xaE7B191A31f627b4eB1d4DaC64eaB9976995b433, | ||
stakingModuleFee: 800, | ||
treasuryFee: 200, | ||
stakeShareLimit: 400, | ||
status: 0, | ||
name: "SimpleDVT", | ||
lastDepositAt: 1735217831, | ||
lastDepositBlock: 21486781, | ||
exitedValidatorsCount: 5, | ||
priorityExitShareThreshold: 444, | ||
maxDepositsPerBlock: 150, | ||
minDepositBlockDistance: 25 | ||
}); | ||
} | ||
|
||
if (_stakingModuleId == 3) { | ||
return | ||
StakingRouter.StakingModule({ | ||
id: 3, | ||
stakingModuleAddress: 0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F, | ||
stakingModuleFee: 600, | ||
treasuryFee: 400, | ||
stakeShareLimit: 100, | ||
status: 0, | ||
name: "Community Staking", | ||
lastDepositAt: 1735217387, | ||
lastDepositBlock: 21486745, | ||
exitedValidatorsCount: 104, | ||
priorityExitShareThreshold: 125, | ||
maxDepositsPerBlock: 30, | ||
minDepositBlockDistance: 25 | ||
}); | ||
} | ||
} | ||
} |
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.
Better to put it into test/0.8.25/contracts and rename it like SecondOpinionOracle__MockForAccountingFuzzing