-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement
getDepletionTime()
(#118)
* feat: function depletionTimeOf() * test: rename defaultDeposit to depositToDefaultStream * refactor: use uint40 for the return value of depletionTimeOf refactor: improve readability in depletionTimeOf --------- Co-authored-by: andreivladbrg <[email protected]>
- Loading branch information
1 parent
ef8b7ce
commit 0835718
Showing
13 changed files
with
112 additions
and
16 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
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
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
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,42 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.22; | ||
|
||
import { Integration_Test } from "../Integration.t.sol"; | ||
|
||
contract DepletionTimeOf_Integration_Test is Integration_Test { | ||
function test_RevertGiven_Null() external { | ||
// it should revert | ||
expectRevertNull(); | ||
openEnded.depletionTimeOf(nullStreamId); | ||
} | ||
|
||
function test_RevertGiven_Paused() external givenNotNull { | ||
// it should revert | ||
expectRevertPaused(); | ||
openEnded.depletionTimeOf(defaultStreamId); | ||
} | ||
|
||
function test_WhenBalanceIsZero() external view givenNotNull givenNotPaused { | ||
// it should return 0 | ||
uint40 depletionTime = openEnded.depletionTimeOf(defaultStreamId); | ||
assertEq(depletionTime, 0, "depletion time"); | ||
} | ||
|
||
modifier whenBalanceIsNotZero() { | ||
depositToDefaultStream(); | ||
_; | ||
} | ||
|
||
function test_WhenStreamHasDebt() external givenNotNull givenNotPaused whenBalanceIsNotZero { | ||
vm.warp({ newTimestamp: block.timestamp + SOLVENCY_PERIOD }); | ||
// it should return 0 | ||
uint40 depletionTime = openEnded.depletionTimeOf(defaultStreamId); | ||
assertEq(depletionTime, 0, "depletion time"); | ||
} | ||
|
||
function test_WhenStreamHasNoDebt() external givenNotNull givenNotPaused whenBalanceIsNotZero { | ||
// it should return the time at which the stream depletes its balance | ||
uint40 depletionTime = openEnded.depletionTimeOf(defaultStreamId); | ||
assertEq(depletionTime, block.timestamp + SOLVENCY_PERIOD, "depletion time"); | ||
} | ||
} |
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,14 @@ | ||
DepletionTimeOf_Integration_Test | ||
├── given null | ||
│ └── it should revert | ||
└── given not null | ||
├── given paused | ||
│ └── it should revert | ||
└── given not paused | ||
├── when balance is zero | ||
│ └── it should return 0 | ||
└── when balance is not zero | ||
├── when stream has debt | ||
│ └── it should return 0 | ||
└── when stream has no debt | ||
└── it should return the time at which the stream depletes its balance |
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
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
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
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
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
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
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
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