-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
1 changed file
with
37 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,37 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity ^0.8.13; | ||
|
||
import "../lib/forge-std/src/Test.sol"; | ||
import "./resources/FakePaymentToken.sol"; | ||
import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; | ||
|
||
contract paymentSplitterTest is Test { | ||
FakePaymentToken token; | ||
|
||
function setUp() public { | ||
token = new FakePaymentToken(1000e18, 18); | ||
} | ||
|
||
function testFixedSplit() public { | ||
address[] memory payees = new address[](2); | ||
payees[0] = address(0x1); | ||
payees[1] = address(0x2); | ||
uint256[] memory shares = new uint256[](2); | ||
shares[0] = 8; // 80% | ||
shares[1] = 2; // 20% | ||
PaymentSplitter splitter = new PaymentSplitter(payees, shares); | ||
|
||
// send 100 tokens to the splitter | ||
token.transfer(address(splitter), 100e18); | ||
|
||
// pull share for address 1 | ||
assertEq(token.balanceOf(payees[0]), 0); | ||
splitter.release(token, payees[0]); | ||
assertEq(token.balanceOf(payees[0]), 80e18); | ||
|
||
// pull share for address 2 | ||
assertEq(token.balanceOf(payees[1]), 0); | ||
splitter.release(token, payees[1]); | ||
assertEq(token.balanceOf(payees[1]), 20e18); | ||
} | ||
} |