Move token creation outside of crowdsale contract (#690)

Fixes #358
This commit is contained in:
Santiago Palladino
2018-01-24 11:44:35 -03:00
committed by Francisco Giordano
parent 0541347034
commit 4d7c3cca75
10 changed files with 39 additions and 34 deletions

View File

@ -29,9 +29,9 @@ contract('CappedCrowdsale', function ([_, wallet]) {
this.startTime = latestTime() + duration.weeks(1);
this.endTime = this.startTime + duration.weeks(1);
this.crowdsale = await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, cap);
this.token = MintableToken.at(await this.crowdsale.token());
this.token = await MintableToken.new();
this.crowdsale = await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, cap, this.token.address);
await this.token.transferOwnership(this.crowdsale.address);
});
describe('creating a valid crowdsale', function () {

View File

@ -30,9 +30,9 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
this.endTime = this.startTime + duration.weeks(1);
this.afterEndTime = this.endTime + duration.seconds(1);
this.crowdsale = await Crowdsale.new(this.startTime, this.endTime, rate, wallet);
this.token = MintableToken.at(await this.crowdsale.token());
this.token = await MintableToken.new();
this.crowdsale = await Crowdsale.new(this.startTime, this.endTime, rate, wallet, this.token.address);
await this.token.transferOwnership(this.crowdsale.address);
});
it('should be token owner', async function () {

View File

@ -26,9 +26,11 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
this.endTime = this.startTime + duration.weeks(1);
this.afterEndTime = this.endTime + duration.seconds(1);
this.crowdsale = await FinalizableCrowdsale.new(this.startTime, this.endTime, rate, wallet, { from: owner });
this.token = MintableToken.at(await this.crowdsale.token());
this.token = await MintableToken.new();
this.crowdsale = await FinalizableCrowdsale.new(
this.startTime, this.endTime, rate, wallet, this.token.address, { from: owner }
);
await this.token.transferOwnership(this.crowdsale.address);
});
it('cannot be finalized before ending', async function () {

View File

@ -12,6 +12,7 @@ require('chai')
.should();
const RefundableCrowdsale = artifacts.require('mocks/RefundableCrowdsaleImpl.sol');
const MintableToken = artifacts.require('MintableToken');
contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {
const rate = new BigNumber(1000);
@ -28,7 +29,11 @@ contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {
this.endTime = this.startTime + duration.weeks(1);
this.afterEndTime = this.endTime + duration.seconds(1);
this.crowdsale = await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, goal, { from: owner });
this.token = await MintableToken.new();
this.crowdsale = await RefundableCrowdsale.new(
this.startTime, this.endTime, rate, wallet, goal, this.token.address, { from: owner }
);
await this.token.transferOwnership(this.crowdsale.address);
});
describe('creating a valid crowdsale', function () {

View File

@ -29,8 +29,11 @@ contract('SampleCrowdsale', function ([owner, wallet, investor]) {
this.endTime = this.startTime + duration.weeks(1);
this.afterEndTime = this.endTime + duration.seconds(1);
this.crowdsale = await SampleCrowdsale.new(this.startTime, this.endTime, RATE, GOAL, CAP, wallet);
this.token = SampleCrowdsaleToken.at(await this.crowdsale.token());
this.token = await SampleCrowdsaleToken.new();
this.crowdsale = await SampleCrowdsale.new(
this.startTime, this.endTime, RATE, GOAL, CAP, wallet, this.token.address
);
await this.token.transferOwnership(this.crowdsale.address);
});
it('should create crowdsale with correct parameters', async function () {