-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add 'updateStreamBrokerFee' integration tests
- Loading branch information
1 parent
ed9f088
commit 9f1b4c1
Showing
5 changed files
with
82 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
49 changes: 49 additions & 0 deletions
49
.../integration/concrete/invoice-module/update-stream-broker-fee/updateStreamBrokerFee.t.sol
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: UNLICENSED | ||
pragma solidity ^0.8.26; | ||
|
||
import { Integration_Test } from "../../../Integration.t.sol"; | ||
import { Types } from "./../../../../../src/modules/invoice-module/libraries/Types.sol"; | ||
import { Errors } from "../../../../utils/Errors.sol"; | ||
import { Events } from "../../../../utils/Events.sol"; | ||
import { ud, UD60x18 } from "@prb/math/src/UD60x18.sol"; | ||
|
||
contract UpdateStreamBrokerFee_Integration_Concret_Test is Integration_Test { | ||
Types.Invoice invoice; | ||
|
||
function setUp() public virtual override { | ||
Integration_Test.setUp(); | ||
} | ||
|
||
function test_RevertWhen_CallerNotOwner() external { | ||
// Make Bob the caller in this test suite who is not the broker admin | ||
vm.startPrank({ msgSender: users.bob }); | ||
|
||
// Expect the call to revert with the {OnlyBrokerAdmin} error | ||
vm.expectRevert(Errors.OnlyBrokerAdmin.selector); | ||
|
||
// Run the test | ||
mockStreamManager.updateStreamBrokerFee({ newBrokerFee: ud(0.05e18) }); | ||
} | ||
|
||
modifier whenCallerBrokerAdmin() { | ||
// Make Admin the caller in this test suite | ||
vm.startPrank({ msgSender: users.admin }); | ||
|
||
_; | ||
} | ||
|
||
function test_UpdateStreamBrokerFee() external whenCallerBrokerAdmin { | ||
UD60x18 newBrokerFee = ud(0.05e18); | ||
|
||
// Expect the {BrokerFeeUpdated} to be emitted | ||
vm.expectEmit(); | ||
emit Events.BrokerFeeUpdated({ oldFee: ud(0), newFee: newBrokerFee }); | ||
|
||
// Run the test | ||
mockStreamManager.updateStreamBrokerFee(newBrokerFee); | ||
|
||
// Assert the actual and expected broker fee | ||
UD60x18 actualBrokerFee = mockStreamManager.brokerFee(); | ||
assertEq(UD60x18.unwrap(actualBrokerFee), UD60x18.unwrap(newBrokerFee)); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
test/integration/concrete/invoice-module/update-stream-broker-fee/updateStreamBrokerFee.tree
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,6 @@ | ||
updateStreamBrokerFee.t.sol | ||
├── when the caller IS NOT the broker admin | ||
│ └── it should revert with the {OnlyBrokerAdmin} error | ||
└── when the caller IS the broker admin | ||
└── it should update the broker admin | ||
└── it should emit a {BrokerFeeUpdated} event |
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,16 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity ^0.8.26; | ||
|
||
import { StreamManager } from "./../../src/modules/invoice-module/sablier-v2/StreamManager.sol"; | ||
import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; | ||
import { ISablierV2LockupTranched } from "@sablier/v2-core/src/interfaces/ISablierV2LockupTranched.sol"; | ||
|
||
/// @title MockStreamManager | ||
/// @notice A mock implementation of the `StreamManager` contract | ||
contract MockStreamManager is StreamManager { | ||
constructor( | ||
ISablierV2LockupLinear _sablierLockupLinear, | ||
ISablierV2LockupTranched _sablierLockupTranched, | ||
address _brokerAdmin | ||
) StreamManager(_sablierLockupLinear, _sablierLockupTranched, _brokerAdmin) { } | ||
} |
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