-
-
Save PaulRBerg/d49bf9d2e078de83c7162e770ae0cdef to your computer and use it in GitHub Desktop.
V2 testing branching structure for "create" function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// solhint-disable max-line-length | |
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.13; | |
import { IERC20 } from "@prb/contracts/token/erc20/IERC20.sol"; | |
import { ISablierV2 } from "@sablier/v2-core/interfaces/ISablierV2.sol"; | |
import { ISablierV2Pro } from "@sablier/v2-core/interfaces/ISablierV2Pro.sol"; | |
import { SafeERC20__CallToNonContract } from "@prb/contracts/token/erc20/SafeERC20.sol"; | |
import { SCALE, SD59x18 } from "@prb/math/SD59x18.sol"; | |
import { stdError } from "forge-std/Test.sol"; | |
import { SablierV2ProUnitTest } from "../SablierV2ProUnitTest.t.sol"; | |
contract SablierV2Pro__UnitTest__Create is SablierV2ProUnitTest { | |
/// @dev it should revert. | |
function testCannotCreate__RecipientZeroAddress() external { | |
vm.expectRevert(ISablierV2.SablierV2__RecipientZeroAddress.selector); | |
address recipient = address(0); | |
sablierV2Pro.create( | |
daiStream.sender, | |
recipient, | |
daiStream.depositAmount, | |
daiStream.token, | |
daiStream.startTime, | |
daiStream.segmentAmounts, | |
daiStream.segmentExponents, | |
daiStream.segmentMilestones, | |
daiStream.cancelable | |
); | |
} | |
/// @dev it should revert. | |
function testCannotCreate__RecipientNonZeroAddress__DepositAmountZero() external { | |
vm.expectRevert(ISablierV2.SablierV2__DepositAmountZero.selector); | |
uint256 depositAmount = 0; | |
sablierV2Pro.create( | |
daiStream.sender, | |
daiStream.recipient, | |
depositAmount, | |
daiStream.token, | |
daiStream.startTime, | |
daiStream.segmentAmounts, | |
daiStream.segmentExponents, | |
daiStream.segmentMilestones, | |
daiStream.cancelable | |
); | |
} | |
/// @dev it should create the stream. | |
function testCreate__RecipientNonZeroAddress__DepositAmountNotZero__SegmentCountNotZero__SegmentCountWithinBounds__SegmentCountNotEqual__StartTimeLessThanStopTime__SegmentAmountsSumDoesNotOverflow__SegmentMilestonesOrdered__SegmentExponentsWithinBounds__DepositAmountEqualtoSegmentAmountsSum__TokenERC20Compliant__Token18Decimals__CallerNotSender() | |
external | |
{ | |
// Make Alice the funder of the stream. | |
changePrank(users.alice); | |
uint256 daiStreamId = createDefaultDaiStream(); | |
// Run the test. | |
ISablierV2Pro.Stream memory actualStream = sablierV2Pro.getStream(daiStreamId); | |
ISablierV2Pro.Stream memory expectedStream = daiStream; | |
assertEq(actualStream, expectedStream); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment