MintedCrowdsale.test.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behavior');
  2. const { ether } = require('../helpers/ether');
  3. const BigNumber = web3.BigNumber;
  4. const MintedCrowdsale = artifacts.require('MintedCrowdsaleImpl');
  5. const MintableToken = artifacts.require('MintableToken');
  6. const RBACMintableToken = artifacts.require('RBACMintableToken');
  7. contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) {
  8. const rate = new BigNumber(1000);
  9. const value = ether(5);
  10. describe('using MintableToken', function () {
  11. beforeEach(async function () {
  12. this.token = await MintableToken.new();
  13. this.crowdsale = await MintedCrowdsale.new(rate, wallet, this.token.address);
  14. await this.token.transferOwnership(this.crowdsale.address);
  15. });
  16. it('should be token owner', async function () {
  17. (await this.token.owner()).should.equal(this.crowdsale.address);
  18. });
  19. shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
  20. });
  21. describe('using RBACMintableToken', function () {
  22. const ROLE_MINTER = 'minter';
  23. beforeEach(async function () {
  24. this.token = await RBACMintableToken.new();
  25. this.crowdsale = await MintedCrowdsale.new(rate, wallet, this.token.address);
  26. await this.token.addMinter(this.crowdsale.address);
  27. });
  28. it('should have minter role on token', async function () {
  29. (await this.token.hasRole(this.crowdsale.address, ROLE_MINTER)).should.equal(true);
  30. });
  31. shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
  32. });
  33. });