Remove chai-as-promised (#1116)
* Test: Remove chai-as-promised calls * Test/Helpers: expectThrow accepts optional message * NPM: Remove chai-as-promised * Contracts/DestructibleMock: Fix lint
This commit is contained in:
committed by
Nicolás Venturo
parent
afe9113b18
commit
e6c15b34da
@ -2,6 +2,7 @@ const { ether } = require('../helpers/ether');
|
||||
const { advanceBlock } = require('../helpers/advanceToBlock');
|
||||
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
|
||||
const { latestTime } = require('../helpers/latestTime');
|
||||
const { expectThrow } = require('../helpers/expectThrow');
|
||||
const { EVMRevert } = require('../helpers/EVMRevert');
|
||||
const { assertRevert } = require('../helpers/assertRevert');
|
||||
const { ethGetBalance } = require('../helpers/web3');
|
||||
@ -9,7 +10,6 @@ const { ethGetBalance } = require('../helpers/web3');
|
||||
const BigNumber = web3.BigNumber;
|
||||
|
||||
require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(BigNumber))
|
||||
.should();
|
||||
|
||||
@ -58,8 +58,14 @@ contract('SampleCrowdsale', function ([owner, wallet, investor]) {
|
||||
});
|
||||
|
||||
it('should not accept payments before start', async function () {
|
||||
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert);
|
||||
await this.crowdsale.buyTokens(investor, { from: investor, value: ether(1) }).should.be.rejectedWith(EVMRevert);
|
||||
await expectThrow(
|
||||
this.crowdsale.send(ether(1)),
|
||||
EVMRevert,
|
||||
);
|
||||
await expectThrow(
|
||||
this.crowdsale.buyTokens(investor, { from: investor, value: ether(1) }),
|
||||
EVMRevert,
|
||||
);
|
||||
});
|
||||
|
||||
it('should accept payments during the sale', async function () {
|
||||
@ -67,7 +73,7 @@ contract('SampleCrowdsale', function ([owner, wallet, investor]) {
|
||||
const expectedTokenAmount = RATE.mul(investmentAmount);
|
||||
|
||||
await increaseTimeTo(this.openingTime);
|
||||
await this.crowdsale.buyTokens(investor, { value: investmentAmount, from: investor }).should.be.fulfilled;
|
||||
await this.crowdsale.buyTokens(investor, { value: investmentAmount, from: investor });
|
||||
|
||||
(await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);
|
||||
(await this.token.totalSupply()).should.be.bignumber.equal(expectedTokenAmount);
|
||||
@ -75,14 +81,14 @@ contract('SampleCrowdsale', function ([owner, wallet, investor]) {
|
||||
|
||||
it('should reject payments after end', async function () {
|
||||
await increaseTimeTo(this.afterClosingTime);
|
||||
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert);
|
||||
await this.crowdsale.buyTokens(investor, { value: ether(1), from: investor }).should.be.rejectedWith(EVMRevert);
|
||||
await expectThrow(this.crowdsale.send(ether(1)), EVMRevert);
|
||||
await expectThrow(this.crowdsale.buyTokens(investor, { value: ether(1), from: investor }), EVMRevert);
|
||||
});
|
||||
|
||||
it('should reject payments over cap', async function () {
|
||||
await increaseTimeTo(this.openingTime);
|
||||
await this.crowdsale.send(CAP);
|
||||
await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert);
|
||||
await expectThrow(this.crowdsale.send(1), EVMRevert);
|
||||
});
|
||||
|
||||
it('should allow finalization and transfer funds to wallet if the goal is reached', async function () {
|
||||
@ -105,7 +111,7 @@ contract('SampleCrowdsale', function ([owner, wallet, investor]) {
|
||||
await increaseTimeTo(this.afterClosingTime);
|
||||
|
||||
await this.crowdsale.finalize({ from: owner });
|
||||
await this.crowdsale.claimRefund({ from: investor, gasPrice: 0 }).should.be.fulfilled;
|
||||
await this.crowdsale.claimRefund({ from: investor, gasPrice: 0 });
|
||||
|
||||
const balanceAfterRefund = await ethGetBalance(investor);
|
||||
balanceBeforeInvestment.should.be.bignumber.equal(balanceAfterRefund);
|
||||
|
||||
Reference in New Issue
Block a user