-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Test out admin controls and fix a minor issue in the process
- Loading branch information
1 parent
d821f4c
commit 6f62d4a
Showing
4 changed files
with
65 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import { IPayStreams } from "../../src/interfaces/IPayStreams.sol"; | ||
|
||
import { GlobalHelper } from "../utils/GlobalHelper.sol"; | ||
|
||
contract PayStreamsAdminControlsTest is GlobalHelper { | ||
function test_setFeeInBasisPoints() public { | ||
uint16 newFee = 100; // 1% | ||
|
||
_setFee(newFee); | ||
|
||
assertEq(stream.getFeeInBasisPoints(), newFee); | ||
} | ||
|
||
function test_setGasLimitForHooks() public { | ||
uint256 newGasLimit = 1_000_000; | ||
|
||
_setGasLimitForHooks(newGasLimit); | ||
|
||
assertEq(stream.getGasLimitForHooks(), newGasLimit); | ||
} | ||
|
||
function test_collectFeesFromStream() public { | ||
uint16 newFee = 100; // 1% | ||
|
||
_setFee(newFee); | ||
|
||
(IPayStreams.StreamData memory streamData, IPayStreams.HookConfig memory hookConfig, string memory tag) = | ||
_getTestStreamCreationData(); | ||
_mintAndApprove(streamData.amount); | ||
vm.startPrank(streamer); | ||
bytes32 streamHash = stream.setStream(streamData, hookConfig, tag); | ||
vm.stopPrank(); | ||
|
||
_warpBy(streamData.duration); | ||
stream.collectFundsFromStream(streamHash); | ||
|
||
uint256 expectedFeeAmount = (streamData.amount * newFee) / BPS; | ||
assertEq(token.balanceOf(address(stream)), expectedFeeAmount); | ||
|
||
vm.startPrank(deployer); | ||
stream.collectFees(address(token), expectedFeeAmount); | ||
vm.stopPrank(); | ||
assertEq(token.balanceOf(address(deployer)), expectedFeeAmount); | ||
assertEq(token.balanceOf(address(stream)), 0); | ||
} | ||
} |
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import { GlobalHelper } from "../utils/GlobalHelper.sol"; | ||
|
||
contract PayStreamsInitializationTest is GlobalHelper { | ||
function test_checkFee() public view { | ||
assertEq(stream.getFeeInBasisPoints(), fee); | ||
} | ||
|
||
function test_checkGasLimitForHooks() public view { | ||
assertEq(stream.getGasLimitForHooks(), gasLimitForHooks); | ||
} | ||
} |