Files
openzeppelin-contracts/test/crowdsale/MintedCrowdsale.behavior.js
Yohann Pereira 489d2e85f1 Replace chai.should with chai.expect (#1780)
* changed exxpect to expect wherever applicable

* Merged with latest branch

* Updated merkleTree helper to latest master branch

* Made linting fixes

* Fix for test build

* updated for Coverage

* Updated Address.test.js

* Undo package-lock changes.
2019-06-24 17:40:05 -03:00

44 lines
1.5 KiB
JavaScript

const { balance, expectEvent } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate, value) {
const expectedTokenAmount = rate.mul(value);
describe('as a minted crowdsale', function () {
describe('accepting payments', function () {
it('should accept payments', async function () {
await this.crowdsale.send(value);
await this.crowdsale.buyTokens(investor, { value: value, from: purchaser });
});
});
describe('high-level purchase', function () {
it('should log purchase', async function () {
const { logs } = await this.crowdsale.sendTransaction({ value: value, from: investor });
expectEvent.inLogs(logs, 'TokensPurchased', {
purchaser: investor,
beneficiary: investor,
value: value,
amount: expectedTokenAmount,
});
});
it('should assign tokens to sender', async function () {
await this.crowdsale.sendTransaction({ value: value, from: investor });
expect(await this.token.balanceOf(investor)).to.be.bignumber.equal(expectedTokenAmount);
});
it('should forward funds to wallet', async function () {
const balanceTracker = await balance.tracker(wallet);
await this.crowdsale.sendTransaction({ value, from: investor });
expect(await balanceTracker.delta()).to.be.bignumber.equal(value);
});
});
});
}
module.exports = {
shouldBehaveLikeMintedCrowdsale,
};