Skip to content

Commit 27ae2b2

Browse files
committed
Get tests passing
1 parent 9c18bc6 commit 27ae2b2

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

test/MockFlexVotingClient.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ contract MockFlexVotingClient is FlexVotingClient {
2929
return deposits[_user];
3030
}
3131

32+
// Test hooks
33+
// ---------------------------------------------------------------------------
3234
function exposed_rawBalanceOf(address _user) external view returns (uint208) {
3335
return _rawBalanceOf(_user);
3436
}
@@ -56,6 +58,8 @@ contract MockFlexVotingClient is FlexVotingClient {
5658
function exposed_checkpointRawBalanceOf(address _user) external {
5759
return _checkpointRawBalanceOf(_user);
5860
}
61+
// End test hooks
62+
// ---------------------------------------------------------------------------
5963

6064
/// @notice Allow a holder of the governance token to deposit it into the pool.
6165
/// @param _amount The amount to be deposited.

test/MockFlexVotingDelegatableClient.sol

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,38 @@ contract MockFlexVotingDelegatableClient is FlexVotingDelegatable {
3030
return deposits[_user];
3131
}
3232

33+
// Test hooks
34+
// ---------------------------------------------------------------------------
35+
function exposed_rawBalanceOf(address _user) external view returns (uint208) {
36+
return _rawBalanceOf(_user);
37+
}
38+
39+
function exposed_latestTotalBalance() external view returns (uint208) {
40+
return totalBalanceCheckpoints.latest();
41+
}
42+
43+
function exposed_checkpointTotalBalance(int256 _delta) external {
44+
return _checkpointTotalBalance(_delta);
45+
}
46+
47+
function exposed_castVoteReasonString() external returns (string memory) {
48+
return _castVoteReasonString();
49+
}
50+
51+
function exposed_selfDelegate() external {
52+
return _selfDelegate();
53+
}
54+
55+
function exposed_setDeposits(address _user, uint208 _amount) external {
56+
deposits[_user] = _amount;
57+
}
58+
59+
function exposed_checkpointRawBalanceOf(address _user) external {
60+
return _checkpointRawBalanceOf(_user);
61+
}
62+
// End test hooks
63+
// ---------------------------------------------------------------------------
64+
3365
/// @notice Allow a holder of the governance token to deposit it into the pool.
3466
/// @param _amount The amount to be deposited.
3567
function deposit(uint208 _amount) public {

test/SharedFlexVoting.t.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,19 @@ abstract contract _CheckpointRawBalanceOf is FlexVotingClientTest {
233233
function testFuzz_StoresTheRawBalanceWithTheTimepoint(
234234
address _user,
235235
uint208 _amount,
236-
uint48 _timepoint
236+
uint48 _future
237237
) public {
238238
vm.assume(_user != address(flexClient));
239-
_timepoint = uint48(bound(_timepoint, _now() + 1, type(uint48).max));
239+
_future = uint48(bound(_future, _now() + 1, type(uint48).max));
240240
_amount = uint208(bound(_amount, 1, MAX_VOTES));
241+
uint48 _past = _now();
241242

243+
_advanceTimeTo(_future);
242244
flexClient.exposed_setDeposits(_user, _amount);
243-
assertEq(flexClient.getPastRawBalance(_user, _timepoint), 0);
244-
245-
_advanceTimeTo(_timepoint);
246-
247245
flexClient.exposed_checkpointRawBalanceOf(_user);
248-
assertEq(flexClient.getPastRawBalance(_user, _timepoint), _amount);
246+
247+
assertEq(flexClient.getPastRawBalance(_user, _past), 0);
248+
assertEq(flexClient.getPastRawBalance(_user, _future), _amount);
249249
}
250250
}
251251

0 commit comments

Comments
 (0)