Skip to content

Commit

Permalink
wip: example timewarp with modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc committed Nov 16, 2023
1 parent 146b09a commit c509966
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,9 @@ abstract contract IntegrationBase {
uint[] memory removedShares,
string memory err
) internal {
// Put current state on stack and revert to prior state to fetch
// previous operator shares
uint curState = global.warpToLast();
uint[] memory prevShares = _getOperatorShares(operator, strategies);
global.warpToPresent(curState); // Snap back to reality

uint[] memory curShares = _getOperatorShares(operator, strategies);
// Use timewarp to get previous operator shares
uint[] memory prevShares = _getPrevOperatorShares(operator, strategies);

// For each strategy, check (prev - removed == cur)
for (uint i = 0; i < strategies.length; i++) {
Expand Down Expand Up @@ -238,6 +234,19 @@ abstract contract IntegrationBase {
return expectedShares;
}

modifier timewarp() {
uint curState = global.warpToLast();
_;
global.warpToPresent(curState);
}

function _getPrevOperatorShares(
IUser operator,
IStrategy[] memory strategies
) internal timewarp() view returns (uint[] memory) {
return _getOperatorShares(operator, strategies);
}

/// @dev Looks up each strategy and returns a list of the operator's shares
function _getOperatorShares(IUser operator, IStrategy[] memory strategies) internal view returns (uint[] memory) {
uint[] memory curShares = new uint[](strategies.length);
Expand Down

0 comments on commit c509966

Please sign in to comment.