Skip to content

Commit

Permalink
Fix #1358 Test helper to send funds (#1367)
Browse files Browse the repository at this point in the history
* signing prefix added

* Minor improvement

* Tests changed

* Successfully tested

* Minor improvements

* Minor improvements

* Revert "Dangling commas are now required. (#1359)"

This reverts commit a688977.

* fixes #1358

* linting done

* suggested changes

(cherry picked from commit fa1dfbd)
  • Loading branch information
Aniket-Engg authored and come-maiz committed Oct 20, 2018
1 parent 598a035 commit c25a1e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions test/helpers/sendTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ function sendTransaction (target, name, argsTypes, argsValues, opts) {
return target.sendTransaction(Object.assign({ data: encodedData }, opts));
}

function sendEther (from, to, value) {
web3.eth.sendTransaction({
from: from,
to: to,
value: value,
gasPrice: 0,
});
}
module.exports = {
findMethod,
sendTransaction,
sendEther,
};
9 changes: 5 additions & 4 deletions test/payment/SplitPayment.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { ethGetBalance, ethSendTransaction } = require('../helpers/web3');
const { ethGetBalance } = require('../helpers/web3');
const { sendEther } = require('./../helpers/sendTransaction');
const { ether } = require('../helpers/ether');
const { ZERO_ADDRESS } = require('./../helpers/constants');

Expand Down Expand Up @@ -59,7 +60,7 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
});

it('should accept payments', async function () {
await ethSendTransaction({ from: owner, to: this.contract.address, value: amount });
await sendEther(owner, this.contract.address, amount);

(await ethGetBalance(this.contract.address)).should.be.bignumber.equal(amount);
});
Expand All @@ -77,12 +78,12 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
});

it('should throw if non-payee want to claim', async function () {
await ethSendTransaction({ from: payer1, to: this.contract.address, value: amount });
await sendEther(payer1, this.contract.address, amount);
await expectThrow(this.contract.release(nonpayee1), EVMRevert);
});

it('should distribute funds to payees', async function () {
await ethSendTransaction({ from: payer1, to: this.contract.address, value: amount });
await sendEther(payer1, this.contract.address, amount);

// receive funds
const initBalance = await ethGetBalance(this.contract.address);
Expand Down

0 comments on commit c25a1e3

Please sign in to comment.