a16z / erc4626-tests Goto Github PK
View Code? Open in Web Editor NEWERC4626 Property Tests
License: GNU Affero General Public License v3.0
ERC4626 Property Tests
License: GNU Affero General Public License v3.0
erc4626-tests/ERC4626.test.sol
Lines 36 to 39 in 8b1d7c2
The tests are assuming the vault starts at 1:1 price. The following would be more general:
uint shares = init.share[i];
uint assets = IERC4626(_vault_).previewMint(shares);
try IMockERC20(_underlying_).mint(user, assets) {} catch { vm.assume(false); }
_approve(_underlying_, user, _vault_, assets);
vm.prank(user); try IERC4626(_vault_).mint(shares, user) {} catch { vm.assume(false); }
We are integrating the property test suite as part of the verification of our vault contracts. Unfortunately all tests are failing with the following error:
Test result: FAILED. 0 passed; 1 failed; finished in 15.18s
Failing tests:
Encountered 1 failing test in contracts/test/ERC4626StdTest.sol:ERC4626StdTest
[FAIL. Reason: The `vm.assume` cheatcode rejected too many inputs (65536 allowed)] test_maxDeposit((address[4],uint256[4],uint256[4],int256)) (runs: 22, μ: 447892, ~: 465089)
Encountered a total of 1 failing tests, 0 tests succeeded
I figured that the problem might be related to the fixed upper boud in the maxDeposit()
of the function. The function is implemented to limit the number of assets in the vault. Removing the bound let the test pass, but it does not make sense w.r.t to the contract's logic.
function maxDeposit(address) public view override returns (uint256) {
if (totalAssets() > MAX_TOTAL_ASSETS) {
return 0;
}
return MAX_TOTAL_ASSETS - IERC20(asset()).balanceOf(address(this));
}
Is it possible to bound the "assets" value in fuzzer? For example, an input of 4888566203988820057829237745407778857278425300380918631855130364758515
does not make sense in our case.
[470198] ERC4626StdTest::test_maxDeposit(([0xabAde514b7e828bD42Cb5272b26F2ebBbDa794F0, 0x5D32577cCD88F4c9D850dAD9D4A28ec7F23D963e, 0x683eF4386bbec40e87bF86e2181193Cf91c495AD, 0xbE411Fe80fd84Fe87F69b5356Bd74f8Ce5276EEf], [22698694737177962168034904413051506502332361420, 4888566203988820057829237745407778857278425300380918631855130364758515, 56852593677044934, 32556299], [2692848953710946714442091, 0, 17461643070425363004, 5566649], 0))
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.