MintedCrowdsale.test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behaviour');
  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. const owner = await this.token.owner();
  18. owner.should.equal(this.crowdsale.address);
  19. });
  20. shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
  21. });
  22. describe('using RBACMintableToken', function () {
  23. const ROLE_MINTER = 'minter';
  24. beforeEach(async function () {
  25. this.token = await RBACMintableToken.new();
  26. this.crowdsale = await MintedCrowdsale.new(rate, wallet, this.token.address);
  27. await this.token.addMinter(this.crowdsale.address);
  28. });
  29. it('should have minter role on token', async function () {
  30. const isMinter = await this.token.hasRole(this.crowdsale.address, ROLE_MINTER);
  31. isMinter.should.equal(true);
  32. });
  33. shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
  34. });
  35. });