-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFourSixTwoSixAggBase.t.sol
108 lines (90 loc) · 4.66 KB
/
FourSixTwoSixAggBase.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import "evk/test/unit/evault/EVaultTestBase.t.sol";
import {FourSixTwoSixAgg} from "../../src/FourSixTwoSixAgg.sol";
contract FourSixTwoSixAggBase is EVaultTestBase {
uint256 public constant CASH_RESERVE_ALLOCATION_POINTS = 1000e18;
address deployer;
address user1;
address user2;
address manager;
FourSixTwoSixAgg fourSixTwoSixAgg;
function setUp() public virtual override {
super.setUp();
deployer = makeAddr("Deployer");
user1 = makeAddr("User_1");
user2 = makeAddr("User_2");
vm.startPrank(deployer);
fourSixTwoSixAgg = new FourSixTwoSixAgg(
evc,
address(0),
address(assetTST),
"assetTST_Agg",
"assetTST_Agg",
CASH_RESERVE_ALLOCATION_POINTS,
new address[](0),
new uint256[](0)
);
// grant admin roles to deployer
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.STRATEGY_MANAGER_ROLE_ADMINROLE(), deployer);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.WITHDRAW_QUEUE_MANAGER_ROLE_ADMINROLE(), deployer);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.STRATEGY_ADDER_ROLE_ADMINROLE(), deployer);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.STRATEGY_REMOVER_ROLE_ADMINROLE(), deployer);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.TREASURY_MANAGER_ROLE_ADMINROLE(), deployer);
// grant roles to manager
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.STRATEGY_MANAGER_ROLE(), manager);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.WITHDRAW_QUEUE_MANAGER_ROLE(), manager);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.STRATEGY_ADDER_ROLE(), manager);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.STRATEGY_REMOVER_ROLE(), manager);
fourSixTwoSixAgg.grantRole(fourSixTwoSixAgg.TREASURY_MANAGER_ROLE(), manager);
vm.stopPrank();
}
function testInitialParams() public {
FourSixTwoSixAgg.Strategy memory cashReserve = fourSixTwoSixAgg.getStrategy(address(0));
assertEq(cashReserve.allocated, 0);
assertEq(cashReserve.allocationPoints, CASH_RESERVE_ALLOCATION_POINTS);
assertEq(cashReserve.active, true);
assertEq(
fourSixTwoSixAgg.getRoleAdmin(fourSixTwoSixAgg.STRATEGY_MANAGER_ROLE()),
fourSixTwoSixAgg.STRATEGY_MANAGER_ROLE_ADMINROLE()
);
assertEq(
fourSixTwoSixAgg.getRoleAdmin(fourSixTwoSixAgg.WITHDRAW_QUEUE_MANAGER_ROLE()),
fourSixTwoSixAgg.WITHDRAW_QUEUE_MANAGER_ROLE_ADMINROLE()
);
assertEq(
fourSixTwoSixAgg.getRoleAdmin(fourSixTwoSixAgg.STRATEGY_ADDER_ROLE()),
fourSixTwoSixAgg.STRATEGY_ADDER_ROLE_ADMINROLE()
);
assertEq(
fourSixTwoSixAgg.getRoleAdmin(fourSixTwoSixAgg.STRATEGY_REMOVER_ROLE()),
fourSixTwoSixAgg.STRATEGY_REMOVER_ROLE_ADMINROLE()
);
assertEq(
fourSixTwoSixAgg.getRoleAdmin(fourSixTwoSixAgg.TREASURY_MANAGER_ROLE()),
fourSixTwoSixAgg.TREASURY_MANAGER_ROLE_ADMINROLE()
);
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.STRATEGY_MANAGER_ROLE_ADMINROLE(), deployer));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.WITHDRAW_QUEUE_MANAGER_ROLE_ADMINROLE(), deployer));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.STRATEGY_ADDER_ROLE_ADMINROLE(), deployer));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.STRATEGY_REMOVER_ROLE_ADMINROLE(), deployer));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.TREASURY_MANAGER_ROLE_ADMINROLE(), deployer));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.STRATEGY_MANAGER_ROLE(), manager));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.WITHDRAW_QUEUE_MANAGER_ROLE(), manager));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.STRATEGY_ADDER_ROLE(), manager));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.STRATEGY_REMOVER_ROLE(), manager));
assertTrue(fourSixTwoSixAgg.hasRole(fourSixTwoSixAgg.TREASURY_MANAGER_ROLE(), manager));
}
function _addStrategy(address from, address strategy, uint256 allocationPoints) internal {
vm.prank(from);
fourSixTwoSixAgg.addStrategy(strategy, allocationPoints);
}
function _getWithdrawalQueue() internal view returns (address[] memory) {
uint256 length = fourSixTwoSixAgg.withdrawalQueueLength();
address[] memory queue = new address[](length);
for (uint256 i = 0; i < length; ++i) {
queue[i] = fourSixTwoSixAgg.withdrawalQueue(i);
}
return queue;
}
}