Skip to content

Commit

Permalink
add test for PaymentSplitter
Browse files Browse the repository at this point in the history
  • Loading branch information
malteish committed Sep 25, 2023
1 parent a1e0f3f commit 36d0a9f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/PaymentSplitter.t.sol
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);
}
}

0 comments on commit 36d0a9f

Please sign in to comment.