-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72c2d34
commit fe4755f
Showing
1 changed file
with
160 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.22; | ||
|
||
import { ud21x18 } from "@prb/math/src/UD21x18.sol"; | ||
|
||
import { Integration_Test, Flow } from "../../Integration.t.sol"; | ||
|
||
contract Getters_Integration_Concrete_Test is Integration_Test { | ||
function setUp() public override { | ||
Integration_Test.setUp(); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
GETTERS-REVERT | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function test_RevertGiven_Null_Balance() external { | ||
bytes memory callData = abi.encodeCall(flow.getBalance, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_RatePerSecond() external { | ||
bytes memory callData = abi.encodeCall(flow.getRatePerSecond, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_Recipient() external { | ||
bytes memory callData = abi.encodeCall(flow.getRecipient, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_Sender() external { | ||
bytes memory callData = abi.encodeCall(flow.getSender, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_SnapshotDebtScaled() external { | ||
bytes memory callData = abi.encodeCall(flow.getSnapshotDebtScaled, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_SnapshotTime() external { | ||
bytes memory callData = abi.encodeCall(flow.getSnapshotTime, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_Paused() external { | ||
bytes memory callData = abi.encodeCall(flow.isPaused, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_Stream() external { | ||
bytes memory callData = abi.encodeCall(flow.getStream, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_TokenDecimals() external { | ||
bytes memory callData = abi.encodeCall(flow.getTokenDecimals, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_Transferable() external { | ||
bytes memory callData = abi.encodeCall(flow.isTransferable, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
function test_RevertGiven_Null_Voided() external { | ||
bytes memory callData = abi.encodeCall(flow.isVoided, (nullStreamId)); | ||
expectRevert_Null(callData); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
GETTERS-CORRECT-VALUE | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function test_NotNull_Balance_NotZero() external { | ||
depositToDefaultStream(); | ||
assertEq(flow.getBalance(defaultStreamId), DEPOSIT_AMOUNT_6D, "balance"); | ||
} | ||
|
||
function test_NotNull_Balance_Zero() external view { | ||
assertEq(flow.getBalance(defaultStreamId), 0, "balance"); | ||
} | ||
|
||
function test_NotNull_IsStream_True() external view { | ||
assertEq(flow.isStream(defaultStreamId), true, "is stream"); | ||
} | ||
|
||
function test_NotNull_Paused_False() external view { | ||
assertEq(flow.isPaused(defaultStreamId), false, "paused"); | ||
} | ||
|
||
function test_NotNull_Paused_True() external { | ||
flow.pause(defaultStreamId); | ||
assertEq(flow.isPaused(defaultStreamId), true, "paused"); | ||
} | ||
|
||
function test_NotNull_RatePerSecond_NotZero() external view { | ||
assertEq(flow.getRatePerSecond(defaultStreamId), RATE_PER_SECOND, "rate per second"); | ||
} | ||
|
||
function test_NotNull_RatePerSecond_Zero() external { | ||
flow.pause(defaultStreamId); | ||
assertEq(flow.getRatePerSecond(defaultStreamId), ud21x18(0), "rate per second"); | ||
} | ||
|
||
function test_NotNull_Recipient() external view { | ||
assertEq(flow.getRecipient(defaultStreamId), users.recipient, "recipient"); | ||
} | ||
|
||
function test_NotNull_Sender() external view { | ||
assertEq(flow.getSender(defaultStreamId), users.sender, "sender"); | ||
} | ||
|
||
function test_NotNull_SnapshotDebtScaled_NotZero() external { | ||
vm.warp(WARP_ONE_MONTH); | ||
flow.adjustRatePerSecond(defaultStreamId, ud21x18(1)); | ||
assertEq(flow.getSnapshotDebtScaled(defaultStreamId), ONE_MONTH_DEBT_18D, "snapshot debt scaled"); | ||
} | ||
|
||
function test_NotNull_SnapshotDebtScaled_Zero() external view { | ||
assertEq(flow.getSnapshotDebtScaled(defaultStreamId), 0, "snapshot debt scaled"); | ||
} | ||
|
||
function test_NotNull_SnapshotTime() external view { | ||
assertEq(flow.getSnapshotTime(defaultStreamId), OCT_1_2024, "snapshot time"); | ||
} | ||
|
||
function test_NotNull_Stream() external view { | ||
Flow.Stream memory stream = defaultStream(); | ||
stream.snapshotTime = OCT_1_2024; | ||
assertEq(abi.encode(flow.getStream(defaultStreamId)), abi.encode(stream), "stream"); | ||
} | ||
|
||
function test_NotNull_TokenDecimals() external view { | ||
assertEq(flow.getTokenDecimals(defaultStreamId), DECIMALS, "token decimals"); | ||
} | ||
|
||
function test_NotNull_Transferable_False() external { | ||
uint256 streamId = flow.create(users.sender, users.recipient, RATE_PER_SECOND, usdc, false); | ||
assertEq(flow.isTransferable(streamId), false, "transferable"); | ||
} | ||
|
||
function test_NotNull_Transferable_True() external view { | ||
assertEq(flow.isTransferable(defaultStreamId), TRANSFERABLE, "transferable"); | ||
} | ||
|
||
function test_NotNull_Voided_False() external view { | ||
assertEq(flow.isVoided(defaultStreamId), false, "voided"); | ||
} | ||
|
||
function test_NotNull_Voided_True() external { | ||
flow.void(defaultStreamId); | ||
assertEq(flow.isVoided(defaultStreamId), true, "voided"); | ||
} | ||
|
||
function test_Null_IsStream_False() external view { | ||
assertEq(flow.isStream(nullStreamId), false, "is stream"); | ||
} | ||
} |