diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index 054d36ab5..33910695c 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -4,7 +4,7 @@ import '../math/SafeMath.sol'; /** * @title SplitPayment - * @dev Base contract that supports multiple payees claiming funds sent to this contract + * @dev Base contract that supports multiple payees claiming funds sent to this contract * according to the proportion they own. */ contract SplitPayment { @@ -20,7 +20,7 @@ contract SplitPayment { /** * @dev Constructor */ - function SplitPayment(address[] _payees, uint256[] _shares) public { + function SplitPayment(address[] _payees, uint256[] _shares) public payable { require(_payees.length == _shares.length); for (uint256 i = 0; i < _payees.length; i++) { @@ -62,4 +62,9 @@ contract SplitPayment { payee.transfer(payment); } + + /** + * @dev payable fallback + */ + function () public payable {} } diff --git a/test/SplitPayment.js b/test/SplitPayment.js index deed9d10d..c7bafdcc3 100644 --- a/test/SplitPayment.js +++ b/test/SplitPayment.js @@ -6,7 +6,7 @@ const should = require('chai') .should() const EVMThrow = require('./helpers/EVMThrow.js') -const SplitPaymentMock = artifacts.require('./helpers/SplitPaymentMock.sol') +const SplitPayment = artifacts.require('../contracts/payment/SplitPayment.sol') contract('SplitPayment', function ([owner, payee1, payee2, payee3, nonpayee1, payer1]) { const amount = web3.toWei(1.0, 'ether') @@ -15,7 +15,7 @@ contract('SplitPayment', function ([owner, payee1, payee2, payee3, nonpayee1, pa this.payees = [payee1, payee2, payee3] this.shares = [20, 10, 70] - this.contract = await SplitPaymentMock.new(this.payees, this.shares) + this.contract = await SplitPayment.new(this.payees, this.shares) }) it('should accept payments', async function () { @@ -43,7 +43,7 @@ contract('SplitPayment', function ([owner, payee1, payee2, payee3, nonpayee1, pa await web3.eth.sendTransaction({from: payer1, to: this.contract.address, value: amount}) await this.contract.claim({from: nonpayee1}).should.be.rejectedWith(EVMThrow) }) - + it('should distribute funds to payees', async function () { await web3.eth.sendTransaction({from: payer1, to: this.contract.address, value: amount}) diff --git a/test/helpers/SplitPaymentMock.sol b/test/helpers/SplitPaymentMock.sol deleted file mode 100644 index e884d1af8..000000000 --- a/test/helpers/SplitPaymentMock.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma solidity ^0.4.18; - -import '../../contracts/payment/SplitPayment.sol'; - -// mock class using SplitPayment -contract SplitPaymentMock is SplitPayment { - function SplitPaymentMock(address[] _payees, uint256[] _shares) public - SplitPayment(_payees, _shares) payable {} - function () external payable {} -}