-
Notifications
You must be signed in to change notification settings - Fork 73
/
Vault.t.sol
56 lines (41 loc) · 1.46 KB
/
Vault.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.0 <0.9.0;
import {SymTest} from "halmos-cheatcodes/SymTest.sol";
import {Vault} from "../src/Vault.sol";
contract VaultMock is Vault {
function setTotalAssets(uint _totalAssets) public {
totalAssets = _totalAssets;
}
function setTotalShares(uint _totalShares) public {
totalShares = _totalShares;
}
}
/// @custom:halmos --solver-timeout-assertion 0
contract VaultTest is SymTest {
VaultMock vault;
function setUp() public {
vault = new VaultMock();
vault.setTotalAssets(svm.createUint256("A1"));
vault.setTotalShares(svm.createUint256("S1"));
}
/// need to set a timeout for this test, the solver can run for hours
/// @custom:halmos --solver-timeout-assertion 10000
function check_deposit(uint assets) public {
uint A1 = vault.totalAssets();
uint S1 = vault.totalShares();
vault.deposit(assets);
uint A2 = vault.totalAssets();
uint S2 = vault.totalShares();
// assert(A1 / S1 <= A2 / S2);
assert(A1 * S2 <= A2 * S1); // no counterexample
}
function check_mint(uint shares) public {
uint A1 = vault.totalAssets();
uint S1 = vault.totalShares();
vault.mint(shares);
uint A2 = vault.totalAssets();
uint S2 = vault.totalShares();
// assert(A1 / S1 <= A2 / S2);
assert(A1 * S2 <= A2 * S1); // counterexamples exist
}
}