MintedCrowdsale.test.js 1.6 KB

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