Skip to content

Commit

Permalink
chore: move constants to Waterfalltesthelper
Browse files Browse the repository at this point in the history
  • Loading branch information
samparsky committed Aug 1, 2023
1 parent 35541de commit 49b05cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 42 deletions.
43 changes: 1 addition & 42 deletions src/test/waterfall/WaterfallModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {MockERC20} from "../utils/mocks/MockERC20.sol";
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
import {WaterfallTestHelper} from "./WaterfallTestHelper.t.sol";

contract WaterfallModuleTest is Test {
contract WaterfallModuleTest is WaterfallTestHelper, Test {
using SafeTransferLib for address;

event CreateWaterfallModule(
Expand All @@ -29,12 +29,6 @@ contract WaterfallModuleTest is Test {
address nonWaterfallToken, address recipient, uint256 amount
);

address internal constant ETH_ADDRESS = address(0);

uint256 internal constant MAX_TRANCHE_SIZE = 2;
uint256 internal constant BALANCE_CLASSIFICATION_THRESHOLD = 16 ether;
uint256 internal constant ETH_STAKE = 32 ether;

WaterfallModule public waterfallModule;
WaterfallModuleFactory public waterfallModuleFactory;
address public nonWaterfallRecipient;
Expand Down Expand Up @@ -841,39 +835,4 @@ contract WaterfallModuleTest is Test {
}
}

/// -----------------------------------------------------------------------
/// helper fns
/// -----------------------------------------------------------------------

function generateTranches(uint256 rSeed, uint256 tSeed)
internal
pure
returns (address[] memory recipients, uint256 threshold)
{
recipients = generateTrancheRecipients(MAX_TRANCHE_SIZE, rSeed);
threshold = generateTrancheThreshold(tSeed);
}

function generateTrancheRecipients(uint256 numRecipients, uint256 _seed)
internal
pure
returns (address[] memory recipients)
{
recipients = new address[](numRecipients);
bytes32 seed = bytes32(_seed);
for (uint256 i = 0; i < numRecipients; i++) {
seed = keccak256(abi.encodePacked(seed));
recipients[i] = address(bytes20(seed));
}
}

function generateTrancheThreshold(uint256 _seed)
internal
pure
returns (uint256 threshold)
{
uint256 seed = _seed;
seed = uint256(keccak256(abi.encodePacked(seed)));
threshold = uint96(seed);
}
}
2 changes: 2 additions & 0 deletions src/test/waterfall/WaterfallTestHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ contract WaterfallTestHelper {

uint256 internal constant ETH_STAKE = 32 ether;

uint256 internal constant BALANCE_CLASSIFICATION_THRESHOLD = 16 ether;

/// -----------------------------------------------------------------------
/// helper fns
/// -----------------------------------------------------------------------
Expand Down

0 comments on commit 49b05cf

Please sign in to comment.