Skip to content

Commit

Permalink
#36 + test
Browse files Browse the repository at this point in the history
  • Loading branch information
enkogu committed Nov 8, 2018
1 parent e45f6ed commit e740a08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 13 additions & 0 deletions contracts/ether/WeiSplitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import "../interfaces/IWeiReceiver.sol";
* if they have ended.
*/
contract WeiSplitter is SplitterBase, IWeiReceiver {
Type splitterChildrenType = Type.Splitter;

struct FlowBuffer {
uint flow;
bool relSeqQ;
Expand Down Expand Up @@ -98,4 +100,15 @@ contract WeiSplitter is SplitterBase, IWeiReceiver {

return b;
}

function addChild(address _newChild) public onlyOwner {
if((splitterChildrenType!=Type.Splitter)
&&(IWeiReceiver(_newChild).getReceiverType()!=Type.Splitter)) {
require(IWeiReceiver(_newChild).getReceiverType()==splitterChildrenType);
} else {
splitterChildrenType = IWeiReceiver(_newChild).getReceiverType();
}

super.addChild(_newChild);
}
}
5 changes: 2 additions & 3 deletions test/moneyflow.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,12 @@ contract('Moneyflow', (accounts) => {
const employee2 = accounts[2];
const outsider = accounts[3];

it('Should revert when some money stays on splitter (U-> abs-rel50%)', async () => {
it('Should revert when trying to add rel to abs splitter', async () => {
var abs = await WeiAbsoluteExpense.new(1e15, 1e15);
var splitter = await WeiSplitter.new();
var rel = await WeiRelativeExpense.new(500000);
await splitter.addChild(abs.address);
await splitter.addChild(rel.address);
await splitter.processFunds(1e16, { value: 1e16 }).should.be.rejectedWith('revert');
await splitter.addChild(rel.address).should.be.rejectedWith('revert');
});


Expand Down

0 comments on commit e740a08

Please sign in to comment.