Skip to content

Commit

Permalink
#55
Browse files Browse the repository at this point in the history
  • Loading branch information
enkogu committed Jan 4, 2019
1 parent 2f45abc commit 4a64ec3
Show file tree
Hide file tree
Showing 9 changed files with 1,351 additions and 2,325 deletions.
920 changes: 256 additions & 664 deletions test/ERC20_tests/ERC20_expense.tests.js

Large diffs are not rendered by default.

39 changes: 10 additions & 29 deletions test/ERC20_tests/ERC20_fund.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,16 @@ var ERC20RelativeExpense = artifacts.require('./ERC20RelativeExpense');
var ERC20AbsoluteExpenseWithPeriod = artifacts.require('./ERC20AbsoluteExpenseWithPeriod');
var ERC20RelativeExpenseWithPeriod = artifacts.require('./ERC20RelativeExpenseWithPeriod');
var ERC20AbsoluteExpenseWithPeriodSliding = artifacts.require('./ERC20AbsoluteExpenseWithPeriodSliding');
const getEId = o => o.logs.filter(l => l.event == 'elementAdded')[0].args._eId.toNumber();
const KECCAK256 = x => web3.sha3(x);

async function passHours (hours) {
await web3.currentProvider.sendAsync({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [3600 * hours * 1000],
id: new Date().getTime(),
}, function (err) { if (err) console.log('err:', err); });
}

const BigNumber = web3.BigNumber;

require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.use(require('chai-bignumber')(web3.BigNumber))
.should();

const {passHours} = require('../helpers/utils');

contract('ERC20Fund', (accounts) => {
var token;
let tokenAmount = 1e7;

const creator = accounts[0];
const employee1 = accounts[1];
Expand All @@ -38,19 +26,12 @@ contract('ERC20Fund', (accounts) => {

beforeEach(async () => {
token = await StandardToken.new();
await token.mint(accounts[0], 1e25);
await token.mint(accounts[1], 1e25);
await token.mint(accounts[2], 1e25);
await token.mint(accounts[3], 1e25);
await token.mint(accounts[4], 1e25);
await token.mint(accounts[5], 1e25);
await token.mint(accounts[6], 1e25);
await token.mint(accounts[7], 1e25);
await token.mint(accounts[8], 1e25);
await token.mint(accounts[9], 1e25);
for(var i=0; i<10; i++) {
await token.mint(accounts[i], 1e25);
}
});

it('Should collect tokenAmount, then revert if more, then flush', async () => {
it('Should collect, then revert if more, then flush', async () => {
let fund = await ERC20AbsoluteExpense.new(token.address,1e18, 0);

var totalNeed = await fund.getTotalNeeded(1e22);
Expand Down Expand Up @@ -99,7 +80,7 @@ contract('ERC20Fund', (accounts) => {
assert.equal(isNeed, false);
});

it('Should collect tokenAmount (periodic, not accumulate debt), then time passed, then need tokenAmount again', async () => {
it('Should collect (periodic, not accumulate debt), then time passed, then need again', async () => {
let fund = await ERC20AbsoluteExpenseWithPeriod.new(token.address,1e18, 0, 24);

var totalNeed = await fund.getTotalNeeded(1e22);
Expand Down Expand Up @@ -163,7 +144,7 @@ contract('ERC20Fund', (accounts) => {
assert.equal(isNeed, false);
});

it('Should collect tokenAmount (periodic, accumulate debt), then time passed, then need tokenAmount again', async () => {
it('Should collect (periodic, accumulate debt), then time passed, then need again', async () => {
let fund = await ERC20AbsoluteExpenseWithPeriodSliding.new(token.address,1e18, 0, 24);

var totalNeed = await fund.getTotalNeeded(1e22);
Expand Down Expand Up @@ -224,7 +205,7 @@ contract('ERC20Fund', (accounts) => {
assert.equal(isNeed, false);
});

it('Should collect tokenAmount (periodic, accumulate debt), then time passed, then need tokenAmount again', async () => {
it('Should collect (periodic, accumulate debt), then time passed, then need again', async () => {
let fund = await ERC20AbsoluteExpenseWithPeriodSliding.new(token.address,1e18, 0, 24);
var totalNeed = await fund.getTotalNeeded(1e22);
var isNeed = await fund.isNeeds();
Expand Down
717 changes: 225 additions & 492 deletions test/ERC20_tests/ERC20_table.tests.js

Large diffs are not rendered by default.

391 changes: 391 additions & 0 deletions test/helpers/structures.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions test/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
async function passHours (hours) {
await web3.currentProvider.sendAsync({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [3600 * hours * 1000],
id: new Date().getTime(),
}, function (err) { if (err) console.log('err:', err); });
}

const getNodeId = o => o.logs.filter(l => l.event == 'NodeAdded')[0].args._eId.toNumber();

const BigNumber = web3.BigNumber;

module.exports = {
passHours,
getNodeId
}
875 changes: 235 additions & 640 deletions test/wei_tests/wei_expense.tests.js

Large diffs are not rendered by default.

28 changes: 6 additions & 22 deletions test/wei_tests/wei_fund.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,20 @@ var WeiRelativeExpense = artifacts.require('./WeiRelativeExpense');
var WeiAbsoluteExpenseWithPeriod = artifacts.require('./WeiAbsoluteExpenseWithPeriod');
var WeiRelativeExpenseWithPeriod = artifacts.require('./WeiRelativeExpenseWithPeriod');
var WeiAbsoluteExpenseWithPeriodSliding = artifacts.require('./WeiAbsoluteExpenseWithPeriodSliding');
const getEId = o => o.logs.filter(l => l.event == 'elementAdded')[0].args._eId.toNumber();
const KECCAK256 = x => web3.sha3(x);

async function passHours (hours) {
await web3.currentProvider.sendAsync({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [3600 * hours * 1000],
id: new Date().getTime(),
}, function (err) { if (err) console.log('err:', err); });
}

const BigNumber = web3.BigNumber;

require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.use(require('chai-bignumber')(web3.BigNumber))
.should();

contract('WeiFund', (accounts) => {
let money = web3.toWei(0.001, 'ether');
const {passHours} = require('../helpers/utils');

contract('WeiFund', (accounts) => {
const creator = accounts[0];
const employee1 = accounts[1];
const employee2 = accounts[2];
const outsider = accounts[3];

beforeEach(async () => {
});

it('Should collect money, then revert if more, then flush', async () => {
let fund = await WeiAbsoluteExpense.new(1e18, 0);

Expand Down Expand Up @@ -80,7 +64,7 @@ contract('WeiFund', (accounts) => {
assert.equal(isNeed, false);
});

it('Should collect money (periodic, not accumulate debt), then time passed, then need money again', async () => {
it('Should collect (periodic, not accumulate debt), then time passed, then need again', async () => {
let fund = await WeiAbsoluteExpenseWithPeriod.new(1e18, 0, 24);

var totalNeed = await fund.getTotalNeeded(1e22);
Expand Down Expand Up @@ -141,7 +125,7 @@ contract('WeiFund', (accounts) => {
assert.equal(isNeed, false);
});

it('Should collect money (periodic, accumulate debt), then time passed, then need money again', async () => {
it('Should collect (periodic, accumulate debt), then time passed, then need again', async () => {
let fund = await WeiAbsoluteExpenseWithPeriodSliding.new(1e18, 0, 24);

var totalNeed = await fund.getTotalNeeded(1e22);
Expand Down Expand Up @@ -199,7 +183,7 @@ contract('WeiFund', (accounts) => {
assert.equal(isNeed, false);
});

it('Should collect money (periodic, accumulate debt), then time passed, then need money again', async () => {
it('Should collect (periodic, accumulate debt), then time passed, then need again', async () => {
let fund = await WeiAbsoluteExpenseWithPeriodSliding.new(1e18, 0, 24);
var totalNeed = await fund.getTotalNeeded(1e22);
var isNeed = await fund.isNeeds();
Expand Down
8 changes: 1 addition & 7 deletions test/wei_tests/wei_scheme.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@ var WeiRelativeExpenseWithPeriod = artifacts.require('./WeiRelativeExpenseWithPe

var DefaultMoneyflowSchemeWithUnpackers = artifacts.require('./DefaultMoneyflowSchemeWithUnpackers');

function KECCAK256 (x) {
return web3.sha3(x);
}

contract('Scheme', (accounts) => {
let token;
let store;
let daoBase;
let moneyflowScheme;

let money = web3.toWei(0.001, 'ether');
let money = 1e14;

const creator = accounts[0];
const employee1 = accounts[1];
Expand Down
Loading

0 comments on commit 4a64ec3

Please sign in to comment.