Skip to content
Closed
Prev Previous commit
Next Next commit
resolved all linting errors
  • Loading branch information
lead4good committed Feb 1, 2018
commit 845b58aeda13f0b7b9ffac7fe8e10951e4c3f41a
9 changes: 7 additions & 2 deletions contracts/examples/PreMintedCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ contract PreMintedCrowdsaleVault {
uint256 _endTime,
uint256 _rate,
address _wallet
) public {
)
public
{
token = new SimpleToken();
PseudoMinter _pseudoMinter = new PseudoMinter(token, this);

Expand All @@ -46,7 +48,10 @@ contract PreMintedCrowdsale is Crowdsale {
uint256 _rate,
address _wallet,
Mintable _token
) public Crowdsale(_startTime, _endTime, _rate, _wallet, _token) { }
)
public Crowdsale(_startTime, _endTime, _rate, _wallet, _token)
{
}

// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/MintableToken.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.18;

import './Mintable.sol';
import "./Mintable.sol";
import "./StandardToken.sol";
import "../../ownership/Ownable.sol";

Expand Down
4 changes: 3 additions & 1 deletion test/crowdsale/CappedCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ contract('CappedCrowdsale', function ([_, wallet]) {

describe('creating a valid crowdsale', function () {
it('should fail with zero cap', async function () {
await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, this.token).should.be.rejectedWith(EVMRevert);
await CappedCrowdsale
.new(this.startTime, this.endTime, rate, wallet, 0, this.token)
.should.be.rejectedWith(EVMRevert);
});
});

Expand Down
109 changes: 51 additions & 58 deletions test/examples/PreMintedCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,81 @@
import ether from '../helpers/ether'
import {advanceBlock} from '../helpers/advanceToBlock'
import {increaseTimeTo, duration} from '../helpers/increaseTime'
import latestTime from '../helpers/latestTime'
import EVMRevert from '../helpers/EVMRevert'
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';

const BigNumber = web3.BigNumber
const BigNumber = web3.BigNumber;

require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.should()
.should();

const PreMintedCrowdsale = artifacts.require('PreMintedCrowdsale')
const PreMintedCrowdsaleVault = artifacts.require('PreMintedCrowdsaleVault')
const PseudoMinter = artifacts.require("./token/ERC20/PseudoMinter.sol");
const PreMintedCrowdsale = artifacts.require('PreMintedCrowdsale');
const PreMintedCrowdsaleVault = artifacts.require('PreMintedCrowdsaleVault');
const PseudoMinter = artifacts.require('./token/ERC20/PseudoMinter.sol');

contract('PreMintedCrowdsale', function ([_, wallet]) {

const rate = new BigNumber(1000)
before(async function() {
//Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc
await advanceBlock()
})
const rate = new BigNumber(1000);
before(async function () {
// Advance to the next block to correctly read time in the solidity "now" function interpreted by testrpc
await advanceBlock();
});

beforeEach(async function () {
this.startTime = latestTime() + duration.weeks(1);
this.endTime = this.startTime + duration.weeks(1);
this.endTime = this.startTime + duration.weeks(1);

this.vault = await PreMintedCrowdsaleVault.new(this.startTime, this.endTime, rate, wallet)
this.crowdsale = PreMintedCrowdsale.at(await this.vault.crowdsale())
this.pseudoMinter = PseudoMinter.at(await this.crowdsale.token())
this.tokenCap = new BigNumber(await this.pseudoMinter.availableSupply.call())
this.cap = this.tokenCap.div(rate)
this.lessThanCap = rate
})
this.vault = await PreMintedCrowdsaleVault.new(this.startTime, this.endTime, rate, wallet);
this.crowdsale = PreMintedCrowdsale.at(await this.vault.crowdsale());
this.pseudoMinter = PseudoMinter.at(await this.crowdsale.token());
this.tokenCap = new BigNumber(await this.pseudoMinter.availableSupply.call());
this.cap = this.tokenCap.div(rate);
this.lessThanCap = rate;
});

describe('accepting payments', function () {

beforeEach(async function () {
await increaseTimeTo(this.startTime+ duration.minutes(1))
})
await increaseTimeTo(this.startTime + duration.minutes(1));
});

it('should accept payments within cap', async function () {
await this.crowdsale.send(this.cap.minus(this.lessThanCap)).should.be.fulfilled
await this.crowdsale.send(this.lessThanCap).should.be.fulfilled
})
await this.crowdsale.send(this.cap.minus(this.lessThanCap)).should.be.fulfilled;
await this.crowdsale.send(this.lessThanCap).should.be.fulfilled;
});

it('should reject payments outside cap', async function () {
await this.crowdsale.send(this.cap)
await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert)
})
await this.crowdsale.send(this.cap);
await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert);
});

it('should reject payments that exceed cap', async function () {
await this.crowdsale.send(this.cap.plus(1)).should.be.rejectedWith(EVMRevert)
})

})
await this.crowdsale.send(this.cap.plus(1)).should.be.rejectedWith(EVMRevert);
});
});

describe('ending', function () {

beforeEach(async function () {
await increaseTimeTo(this.startTime)
})
await increaseTimeTo(this.startTime);
});

it('should not be ended if under cap', async function () {
let hasEnded = await this.crowdsale.hasEnded()
hasEnded.should.equal(false)
await this.crowdsale.send(this.lessThanCap)
hasEnded = await this.crowdsale.hasEnded()
hasEnded.should.equal(false)
})
let hasEnded = await this.crowdsale.hasEnded();
hasEnded.should.equal(false);
await this.crowdsale.send(this.lessThanCap);
hasEnded = await this.crowdsale.hasEnded();
hasEnded.should.equal(false);
});

it('should not be ended if just under cap', async function () {
await this.crowdsale.send(this.cap.minus(1))
let hasEnded = await this.crowdsale.hasEnded()
hasEnded.should.equal(false)
})
await this.crowdsale.send(this.cap.minus(1));
let hasEnded = await this.crowdsale.hasEnded();
hasEnded.should.equal(false);
});

it('should be ended if cap reached', async function () {
await this.crowdsale.send(this.cap)
let hasEnded = await this.crowdsale.hasEnded()
hasEnded.should.equal(true)
})

})

})
await this.crowdsale.send(this.cap);
let hasEnded = await this.crowdsale.hasEnded();
hasEnded.should.equal(true);
});
});
});
65 changes: 30 additions & 35 deletions test/token/ERC20/PseudoMinter.test.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,55 @@
import ether from '../../helpers/ether'
import EVMRevert from '../../helpers/EVMRevert'
import EVMRevert from '../../helpers/EVMRevert';

const BigNumber = web3.BigNumber
const BigNumber = web3.BigNumber;

const should = require('chai')
require('chai')
.use(require('chai-as-promised'))
.use(require('chai-bignumber')(BigNumber))
.should()

var PseudoMinter = artifacts.require("./token/ERC20/PseudoMinter.sol");
var SimpleToken = artifacts.require("./example/SimpleToken.sol");
.should();

var PseudoMinter = artifacts.require('./token/ERC20/PseudoMinter.sol');
var SimpleToken = artifacts.require('./example/SimpleToken.sol');

contract('PseudoMinter', function ([owner, tokenAddress]) {

beforeEach(async function () {

this.simpleToken = await SimpleToken.new()
this.pseudoMinter = await PseudoMinter.new(this.simpleToken.address,owner)
this.simpleToken = await SimpleToken.new();
this.pseudoMinter = await PseudoMinter.new(this.simpleToken.address, owner);

this.cap = await this.simpleToken.totalSupply();
this.lessThanCap = 1;

await this.simpleToken.approve(this.pseudoMinter.address, this.cap)
})
await this.simpleToken.approve(this.pseudoMinter.address, this.cap);
});

it('should accept minting within approved cap', async function () {
await this.pseudoMinter.mint(tokenAddress, this.cap.minus(this.lessThanCap)).should.be.fulfilled
await this.pseudoMinter.mint(tokenAddress, this.lessThanCap).should.be.fulfilled
await this.pseudoMinter.mint(tokenAddress, this.cap.minus(this.lessThanCap)).should.be.fulfilled;
await this.pseudoMinter.mint(tokenAddress, this.lessThanCap).should.be.fulfilled;

let amount = await this.simpleToken.balanceOf(tokenAddress)
amount.should.be.bignumber.equal(this.cap)
})
let amount = await this.simpleToken.balanceOf(tokenAddress);
amount.should.be.bignumber.equal(this.cap);
});

it('should reject minting outside approved cap', async function () {
await this.pseudoMinter.mint(tokenAddress, this.cap).should.be.fulfilled
await this.pseudoMinter.mint(tokenAddress, 1).should.be.rejectedWith(EVMRevert)
await this.pseudoMinter.mint(tokenAddress, this.cap).should.be.fulfilled;
await this.pseudoMinter.mint(tokenAddress, 1).should.be.rejectedWith(EVMRevert);

let amount = await this.simpleToken.balanceOf(tokenAddress)
amount.should.be.bignumber.equal(this.cap)
})
let amount = await this.simpleToken.balanceOf(tokenAddress);
amount.should.be.bignumber.equal(this.cap);
});

it('should reject minting that exceed approved cap', async function () {
await this.pseudoMinter.mint(tokenAddress, this.cap.plus(1)).should.be.rejectedWith(EVMRevert)
await this.pseudoMinter.mint(tokenAddress, this.cap.plus(1)).should.be.rejectedWith(EVMRevert);

let amount = await this.simpleToken.balanceOf(tokenAddress)
amount.should.be.bignumber.equal(0)
})
let amount = await this.simpleToken.balanceOf(tokenAddress);
amount.should.be.bignumber.equal(0);
});

it('should be able to change cap by calling tokens approve function', async function () {
await this.simpleToken.approve(this.pseudoMinter.address, 0)

let amount = await this.pseudoMinter.availableSupply.call()
amount.should.be.bignumber.equal(0)
await this.simpleToken.approve(this.pseudoMinter.address, 0);

await this.pseudoMinter.mint(tokenAddress, 1).should.be.rejectedWith(EVMRevert)
})
let amount = await this.pseudoMinter.availableSupply.call();
amount.should.be.bignumber.equal(0);

})
await this.pseudoMinter.mint(tokenAddress, 1).should.be.rejectedWith(EVMRevert);
});
});