SplitPayment now requires payees. (#1131)

* SplitPayment now requires payees.

* Improved test phrasing.
pull/1158/head
Nicolás Venturo 7 years ago committed by GitHub
parent 31ac59b224
commit 94797978bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      contracts/payment/SplitPayment.sol
  2. 14
      test/payment/SplitPayment.test.js

@ -23,6 +23,7 @@ contract SplitPayment {
*/
constructor(address[] _payees, uint256[] _shares) public payable {
require(_payees.length == _shares.length);
require(_payees.length > 0);
for (uint256 i = 0; i < _payees.length; i++) {
addPayee(_payees[i], _shares[i]);

@ -13,6 +13,19 @@ const SplitPayment = artifacts.require('SplitPayment');
contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) {
const amount = web3.toWei(1.0, 'ether');
it('cannot be created with no payees', async function () {
await expectThrow(SplitPayment.new([], []), EVMThrow);
});
it('requires shares for each payee', async function () {
await expectThrow(SplitPayment.new([payee1, payee2, payee3], [20, 30]), EVMThrow);
});
it('requires a payee for each share', async function () {
await expectThrow(SplitPayment.new([payee1, payee2], [20, 30, 40]), EVMThrow);
});
context('once deployed', function () {
beforeEach(async function () {
this.payees = [payee1, payee2, payee3];
this.shares = [20, 10, 70];
@ -78,3 +91,4 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
totalReleased.should.be.bignumber.equal(initBalance);
});
});
});

Loading…
Cancel
Save