MintedCrowdsale.test.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
  2. const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behavior');
  3. const { expect } = require('chai');
  4. const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl');
  5. const ERC20Mintable = artifacts.require('ERC20Mintable');
  6. const ERC20 = artifacts.require('ERC20');
  7. contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]) {
  8. const rate = new BN('1000');
  9. const value = ether('5');
  10. describe('using ERC20Mintable', function () {
  11. beforeEach(async function () {
  12. this.token = await ERC20Mintable.new({ from: deployer });
  13. this.crowdsale = await MintedCrowdsaleImpl.new(rate, wallet, this.token.address);
  14. await this.token.addMinter(this.crowdsale.address, { from: deployer });
  15. await this.token.renounceMinter({ from: deployer });
  16. });
  17. it('crowdsale should be minter', async function () {
  18. expect(await this.token.isMinter(this.crowdsale.address)).to.equal(true);
  19. });
  20. shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
  21. });
  22. describe('using non-mintable token', function () {
  23. beforeEach(async function () {
  24. this.token = await ERC20.new();
  25. this.crowdsale = await MintedCrowdsaleImpl.new(rate, wallet, this.token.address);
  26. });
  27. it('rejects bare payments', async function () {
  28. await expectRevert.unspecified(this.crowdsale.send(value));
  29. });
  30. it('rejects token purchases', async function () {
  31. await expectRevert.unspecified(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }));
  32. });
  33. });
  34. });