No longer assigning awaits to temporary variables. (#1216)
This commit is contained in:
@ -17,11 +17,9 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
it('can accept a single deposit', async function () {
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
|
||||
const balance = await ethGetBalance(this.escrow.address);
|
||||
const deposit = await this.escrow.depositsOf(payee1);
|
||||
(await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(amount);
|
||||
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
deposit.should.be.bignumber.equal(amount);
|
||||
(await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('can accept an empty deposit', async function () {
|
||||
@ -43,24 +41,20 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount * 2 });
|
||||
|
||||
const balance = await ethGetBalance(this.escrow.address);
|
||||
const deposit = await this.escrow.depositsOf(payee1);
|
||||
(await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(amount * 3);
|
||||
|
||||
balance.should.be.bignumber.equal(amount * 3);
|
||||
deposit.should.be.bignumber.equal(amount * 3);
|
||||
(await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount * 3);
|
||||
});
|
||||
|
||||
it('can track deposits to multiple accounts', async function () {
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
await this.escrow.deposit(payee2, { from: owner, value: amount * 2 });
|
||||
|
||||
const balance = await ethGetBalance(this.escrow.address);
|
||||
const depositPayee1 = await this.escrow.depositsOf(payee1);
|
||||
const depositPayee2 = await this.escrow.depositsOf(payee2);
|
||||
(await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(amount * 3);
|
||||
|
||||
balance.should.be.bignumber.equal(amount * 3);
|
||||
depositPayee1.should.be.bignumber.equal(amount);
|
||||
depositPayee2.should.be.bignumber.equal(amount * 2);
|
||||
(await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(amount);
|
||||
|
||||
(await this.escrow.depositsOf(payee2)).should.be.bignumber.equal(amount * 2);
|
||||
});
|
||||
});
|
||||
|
||||
@ -71,12 +65,11 @@ function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
await this.escrow.withdraw(payee1, { from: owner });
|
||||
|
||||
const escrowBalance = await ethGetBalance(this.escrow.address);
|
||||
const finalDeposit = await this.escrow.depositsOf(payee1);
|
||||
const payeeFinalBalance = await ethGetBalance(payee1);
|
||||
(await ethGetBalance(this.escrow.address)).should.be.bignumber.equal(0);
|
||||
|
||||
escrowBalance.should.be.bignumber.equal(0);
|
||||
finalDeposit.should.be.bignumber.equal(0);
|
||||
(await this.escrow.depositsOf(payee1)).should.be.bignumber.equal(0);
|
||||
|
||||
const payeeFinalBalance = await ethGetBalance(payee1);
|
||||
payeeFinalBalance.sub(payeeInitialBalance).should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
|
||||
@ -17,26 +17,22 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
|
||||
|
||||
it('can record an async payment correctly', async function () {
|
||||
await this.contract.callTransfer(payee1, 100, { from: payer });
|
||||
const paymentsToPayee1 = await this.contract.payments(payee1);
|
||||
paymentsToPayee1.should.be.bignumber.equal(100);
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(100);
|
||||
});
|
||||
|
||||
it('can add multiple balances on one account', async function () {
|
||||
await this.contract.callTransfer(payee1, 200, { from: payer });
|
||||
await this.contract.callTransfer(payee1, 300, { from: payer });
|
||||
const paymentsToPayee1 = await this.contract.payments(payee1);
|
||||
paymentsToPayee1.should.be.bignumber.equal(500);
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(500);
|
||||
});
|
||||
|
||||
it('can add balances on multiple accounts', async function () {
|
||||
await this.contract.callTransfer(payee1, 200, { from: payer });
|
||||
await this.contract.callTransfer(payee2, 300, { from: payer });
|
||||
|
||||
const paymentsToPayee1 = await this.contract.payments(payee1);
|
||||
paymentsToPayee1.should.be.bignumber.equal(200);
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(200);
|
||||
|
||||
const paymentsToPayee2 = await this.contract.payments(payee2);
|
||||
paymentsToPayee2.should.be.bignumber.equal(300);
|
||||
(await this.contract.payments(payee2)).should.be.bignumber.equal(300);
|
||||
});
|
||||
|
||||
it('can withdraw payment', async function () {
|
||||
@ -44,12 +40,10 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
|
||||
|
||||
await this.contract.callTransfer(payee1, amount, { from: payer });
|
||||
|
||||
const payment1 = await this.contract.payments(payee1);
|
||||
payment1.should.be.bignumber.equal(amount);
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
|
||||
|
||||
await this.contract.withdrawPayments({ from: payee1 });
|
||||
const payment2 = await this.contract.payments(payee1);
|
||||
payment2.should.be.bignumber.equal(0);
|
||||
(await this.contract.payments(payee1)).should.be.bignumber.equal(0);
|
||||
|
||||
const balance = await ethGetBalance(payee1);
|
||||
Math.abs(balance - initialBalance - amount).should.be.lt(1e16);
|
||||
|
||||
@ -31,8 +31,7 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2]
|
||||
it('accepts deposits', async function () {
|
||||
await this.escrow.deposit(refundee1, { from: owner, value: amount });
|
||||
|
||||
const deposit = await this.escrow.depositsOf(refundee1);
|
||||
deposit.should.be.bignumber.equal(amount);
|
||||
(await this.escrow.depositsOf(refundee1)).should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('does not refund refundees', async function () {
|
||||
|
||||
@ -49,18 +49,15 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
|
||||
it('should accept payments', async function () {
|
||||
await ethSendTransaction({ from: owner, to: this.contract.address, value: amount });
|
||||
|
||||
const balance = await ethGetBalance(this.contract.address);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
(await ethGetBalance(this.contract.address)).should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('should store shares if address is payee', async function () {
|
||||
const shares = await this.contract.shares.call(payee1);
|
||||
shares.should.be.bignumber.not.eq(0);
|
||||
(await this.contract.shares.call(payee1)).should.be.bignumber.not.eq(0);
|
||||
});
|
||||
|
||||
it('should not store shares if address is not payee', async function () {
|
||||
const shares = await this.contract.shares.call(nonpayee1);
|
||||
shares.should.be.bignumber.equal(0);
|
||||
(await this.contract.shares.call(nonpayee1)).should.be.bignumber.equal(0);
|
||||
});
|
||||
|
||||
it('should throw if no funds to claim', async function () {
|
||||
@ -96,12 +93,10 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
|
||||
profit3.sub(web3.toWei(0.70, 'ether')).abs().should.be.bignumber.lt(1e16);
|
||||
|
||||
// end balance should be zero
|
||||
const endBalance = await ethGetBalance(this.contract.address);
|
||||
endBalance.should.be.bignumber.equal(0);
|
||||
(await ethGetBalance(this.contract.address)).should.be.bignumber.equal(0);
|
||||
|
||||
// check correct funds released accounting
|
||||
const totalReleased = await this.contract.totalReleased.call();
|
||||
totalReleased.should.be.bignumber.equal(initBalance);
|
||||
(await this.contract.totalReleased.call()).should.be.bignumber.equal(initBalance);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user