Skip to content

Commit

Permalink
coverage fixes + add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
enkogu committed Jul 16, 2018
1 parent d4b4287 commit 27d44eb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 0 additions & 4 deletions contracts/moneyflow/ether/WeiFund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ contract WeiFund is IWeiReceiver, IDestination, Ownable {//
uint periodHours;

event WeiFund_FlushTo(address _to, uint _balance);
event consoleUint(string a, uint b);

constructor(uint _neededWei, bool _isPeriodic, bool _isAccumulateDebt, uint _periodHours) public {
require(!((_isAccumulateDebt)&&(_periodHours==0)));
Expand All @@ -53,8 +52,6 @@ contract WeiFund is IWeiReceiver, IDestination, Ownable {//
need = 0;
}

emit consoleUint('need', need);
emit consoleUint('_inputWei', _inputWei);
if(need<=_inputWei){
return need;
}else{
Expand Down Expand Up @@ -87,7 +84,6 @@ contract WeiFund is IWeiReceiver, IDestination, Ownable {//
// require(msg.value==_currentFlow);
totalWeiReceived += msg.value;
if(_getTotalWeiNeeded(msg.value)==0){
emit consoleUint('totalWeiReceived', 0);
momentReceived = now;
balanceOnMomentReceived = totalWeiReceived;
}
Expand Down
28 changes: 24 additions & 4 deletions test/moneyflow_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ contract('Moneyflow', (accounts) => {
const outsider = accounts[3];

beforeEach(async() => {
token = await StdDaoToken.new("StdToken","STDT",18, true, true, 1000000000000000000000000000);
token = await StdDaoToken.new("StdToken","STDT",18, true, true, 1000000000000000000000000000, {gasPrice:0});

await token.mintFor(creator, 1000, {gasPrice: 0});

store = await DaoStorage.new([token.address],{from: creator});
daoBase = await DaoBase.new(store.address,{from: creator});
store = await DaoStorage.new([token.address],{from: creator, gasPrice:0});
daoBase = await DaoBase.new(store.address,{from: creator, gasPrice:0});

issueTokens = await daoBase.ISSUE_TOKENS();

Expand All @@ -234,7 +234,7 @@ contract('Moneyflow', (accounts) => {

burnTokens = await daoBase.BURN_TOKENS();

moneyflowInstance = await MoneyFlow.new(daoBase.address);
moneyflowInstance = await MoneyFlow.new(daoBase.address, {gasPrice:0});

withdrawDonations = await moneyflowInstance.WITHDRAW_DONATIONS();

Expand Down Expand Up @@ -262,6 +262,26 @@ contract('Moneyflow', (accounts) => {
//await daoBase.allowActionByAddress("addNewProposal", moneyflowInstance.address);
});

it('Should revert when some money stays on unsorted splitter (U-> abs-rel50%)',async() => {
let abs = await WeiAbsoluteExpense.new(1e15);
let splitter = await WeiUnsortedSplitter.new('splitter');
let rel = await WeiRelativeExpense.new(5000);
await splitter.addChild(abs.address);
await splitter.addChild(rel.address);

await splitter.processFunds(1e16, {value:1e16}).should.be.rejectedWith('revert');
});

it('Should revert when some money stays on topdown splitter (T-> abs-rel50%)',async() => {
let abs = await WeiAbsoluteExpense.new(1e15);
let splitter = await WeiTopDownSplitter.new('splitter');
let rel = await WeiRelativeExpense.new(5000);
await splitter.addChild(abs.address);
await splitter.addChild(rel.address);

await splitter.processFunds(1e16, {value:1e16}).should.be.rejectedWith('revert');
});

it('should process money with WeiAbsoluteExpenseWithPeriod, then 25 hours, then money needs again',async() => {
const CURRENT_INPUT = 30900;
let timePeriod = 25;
Expand Down
2 changes: 1 addition & 1 deletion test/weiFund_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

contract('ConditionalFund', (accounts) => {
contract('WeiFund', (accounts) => {
let money = web3.toWei(0.001, "ether");

const creator = accounts[0];
Expand Down

0 comments on commit 27d44eb

Please sign in to comment.