Update to testrpc 6.0.1 and test fixes for revert opcode.
This commit is contained in:
committed by
Alejandro Santander
parent
b9cbea1c9c
commit
c29dd086d3
6
package-lock.json
generated
6
package-lock.json
generated
@ -2100,9 +2100,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereumjs-testrpc": {
|
"ethereumjs-testrpc": {
|
||||||
"version": "4.1.1",
|
"version": "6.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-testrpc/-/ethereumjs-testrpc-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ethereumjs-testrpc/-/ethereumjs-testrpc-6.0.1.tgz",
|
||||||
"integrity": "sha512-NQjL/5chwWVjCOzVfsExdkw2yN+atFPGUVfxhyCh27fLBREcK0X2KU72b2kLaqkd4nIEjd68+O3zMtExzf43+w==",
|
"integrity": "sha1-CdoVoUox2jhPsQwIwPqaxXasgTc=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"webpack": "3.5.4"
|
"webpack": "3.5.4"
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
"chai-bignumber": "^2.0.0",
|
"chai-bignumber": "^2.0.0",
|
||||||
"coveralls": "^2.13.1",
|
"coveralls": "^2.13.1",
|
||||||
"ethereumjs-util": "^5.1.2",
|
"ethereumjs-util": "^5.1.2",
|
||||||
"ethereumjs-testrpc": "^4.1.1",
|
"ethereumjs-testrpc": "^6.0.1",
|
||||||
"mocha-lcov-reporter": "^1.3.0",
|
"mocha-lcov-reporter": "^1.3.0",
|
||||||
"solidity-coverage": "^0.2.2",
|
"solidity-coverage": "^0.2.2",
|
||||||
"truffle": "^4.0.0",
|
"truffle": "^4.0.0",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
|
|
||||||
var BasicTokenMock = artifacts.require("./helpers/BasicTokenMock.sol");
|
var BasicTokenMock = artifacts.require("./helpers/BasicTokenMock.sol");
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ contract('BasicToken', function(accounts) {
|
|||||||
let transfer = await token.transfer(accounts[1], 101);
|
let transfer = await token.transfer(accounts[1], 101);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ contract('BasicToken', function(accounts) {
|
|||||||
let transfer = await token.transfer(0x0, 100);
|
let transfer = await token.transfer(0x0, 100);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const EVMThrow = require('./helpers/EVMThrow.js')
|
const EVMRevert = require('./helpers/EVMRevert.js')
|
||||||
const BurnableTokenMock = artifacts.require("./helpers/BurnableTokenMock.sol")
|
const BurnableTokenMock = artifacts.require("./helpers/BurnableTokenMock.sol")
|
||||||
const BigNumber = web3.BigNumber
|
const BigNumber = web3.BigNumber
|
||||||
|
|
||||||
@ -34,6 +34,6 @@ contract('BurnableToken', function (accounts) {
|
|||||||
|
|
||||||
it('cannot burn more tokens than your balance', async function () {
|
it('cannot burn more tokens than your balance', async function () {
|
||||||
await token.burn(2000, { from: accounts[0] })
|
await token.burn(2000, { from: accounts[0] })
|
||||||
.should.be.rejectedWith(EVMThrow)
|
.should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import ether from './helpers/ether'
|
|||||||
import {advanceBlock} from './helpers/advanceToBlock'
|
import {advanceBlock} from './helpers/advanceToBlock'
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
||||||
import latestTime from './helpers/latestTime'
|
import latestTime from './helpers/latestTime'
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
|
|
||||||
const BigNumber = web3.BigNumber
|
const BigNumber = web3.BigNumber
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ contract('CappedCrowdsale', function ([_, wallet]) {
|
|||||||
describe('creating a valid crowdsale', function () {
|
describe('creating a valid crowdsale', function () {
|
||||||
|
|
||||||
it('should fail with zero cap', async function () {
|
it('should fail with zero cap', async function () {
|
||||||
await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0).should.be.rejectedWith(EVMThrow);
|
await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0).should.be.rejectedWith(EVMRevert);
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -56,11 +56,11 @@ contract('CappedCrowdsale', function ([_, wallet]) {
|
|||||||
|
|
||||||
it('should reject payments outside cap', async function () {
|
it('should reject payments outside cap', async function () {
|
||||||
await this.crowdsale.send(cap)
|
await this.crowdsale.send(cap)
|
||||||
await this.crowdsale.send(1).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should reject payments that exceed cap', async function () {
|
it('should reject payments that exceed cap', async function () {
|
||||||
await this.crowdsale.send(cap.plus(1)).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.send(cap.plus(1)).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
|
|
||||||
var Claimable = artifacts.require('../contracts/ownership/Claimable.sol');
|
var Claimable = artifacts.require('../contracts/ownership/Claimable.sol');
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ contract('Claimable', function(accounts) {
|
|||||||
await claimable.claimOwnership({from: accounts[2]});
|
await claimable.claimOwnership({from: accounts[2]});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ contract('Claimable', function(accounts) {
|
|||||||
await claimable.transferOwnership(other, {from: other});
|
await claimable.transferOwnership(other, {from: other});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
|
|
||||||
var Contactable = artifacts.require('../contracts/ownership/Contactable.sol');
|
var Contactable = artifacts.require('../contracts/ownership/Contactable.sol');
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import ether from './helpers/ether'
|
|||||||
import {advanceBlock} from './helpers/advanceToBlock'
|
import {advanceBlock} from './helpers/advanceToBlock'
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
||||||
import latestTime from './helpers/latestTime'
|
import latestTime from './helpers/latestTime'
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
|
|
||||||
const BigNumber = web3.BigNumber
|
const BigNumber = web3.BigNumber
|
||||||
|
|
||||||
@ -53,8 +53,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
|
|||||||
describe('accepting payments', function () {
|
describe('accepting payments', function () {
|
||||||
|
|
||||||
it('should reject payments before start', async function () {
|
it('should reject payments before start', async function () {
|
||||||
await this.crowdsale.send(value).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert)
|
||||||
await this.crowdsale.buyTokens(investor, {from: purchaser, value: value}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.buyTokens(investor, {from: purchaser, value: value}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should accept payments after start', async function () {
|
it('should accept payments after start', async function () {
|
||||||
@ -65,8 +65,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
|
|||||||
|
|
||||||
it('should reject payments after end', async function () {
|
it('should reject payments after end', async function () {
|
||||||
await increaseTimeTo(this.afterEndTime)
|
await increaseTimeTo(this.afterEndTime)
|
||||||
await this.crowdsale.send(value).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert)
|
||||||
await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
import latestTime from './helpers/latestTime'
|
import latestTime from './helpers/latestTime'
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ contract('DayLimit', function(accounts) {
|
|||||||
await dayLimit.attemptSpend(3);
|
await dayLimit.attemptSpend(3);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ contract('DayLimit', function(accounts) {
|
|||||||
await dayLimit.attemptSpend(3);
|
await dayLimit.attemptSpend(3);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
spentToday = await dayLimit.spentToday();
|
spentToday = await dayLimit.spentToday();
|
||||||
assert.equal(spentToday, 8);
|
assert.equal(spentToday, 8);
|
||||||
@ -72,7 +72,7 @@ contract('DayLimit', function(accounts) {
|
|||||||
await dayLimit.attemptSpend(3);
|
await dayLimit.attemptSpend(3);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
spentToday = await dayLimit.spentToday();
|
spentToday = await dayLimit.spentToday();
|
||||||
assert.equal(spentToday, 8);
|
assert.equal(spentToday, 8);
|
||||||
@ -95,7 +95,7 @@ contract('DayLimit', function(accounts) {
|
|||||||
await dayLimit.attemptSpend(3);
|
await dayLimit.attemptSpend(3);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
spentToday = await dayLimit.spentToday();
|
spentToday = await dayLimit.spentToday();
|
||||||
assert.equal(spentToday, 8);
|
assert.equal(spentToday, 8);
|
||||||
|
|||||||
@ -49,7 +49,7 @@ contract('DelayedClaimable', function(accounts) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
err = error;
|
err = error;
|
||||||
}
|
}
|
||||||
assert.isFalse(err.message.search('invalid opcode') === -1);
|
assert.isFalse(err.message.search('revert') === -1);
|
||||||
let owner = await delayedClaimable.owner();
|
let owner = await delayedClaimable.owner();
|
||||||
assert.isTrue(owner !== accounts[1]);
|
assert.isTrue(owner !== accounts[1]);
|
||||||
});
|
});
|
||||||
@ -62,7 +62,7 @@ contract('DelayedClaimable', function(accounts) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
err = error;
|
err = error;
|
||||||
}
|
}
|
||||||
assert.isFalse(err.message.search('invalid opcode') === -1);
|
assert.isFalse(err.message.search('revert') === -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import {advanceBlock} from './helpers/advanceToBlock'
|
import {advanceBlock} from './helpers/advanceToBlock'
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
||||||
import latestTime from './helpers/latestTime'
|
import latestTime from './helpers/latestTime'
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
|
|
||||||
const BigNumber = web3.BigNumber
|
const BigNumber = web3.BigNumber
|
||||||
|
|
||||||
@ -34,12 +34,12 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('cannot be finalized before ending', async function () {
|
it('cannot be finalized before ending', async function () {
|
||||||
await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('cannot be finalized by third party after ending', async function () {
|
it('cannot be finalized by third party after ending', async function () {
|
||||||
await increaseTimeTo(this.afterEndTime)
|
await increaseTimeTo(this.afterEndTime)
|
||||||
await this.crowdsale.finalize({from: thirdparty}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.finalize({from: thirdparty}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be finalized by owner after ending', async function () {
|
it('can be finalized by owner after ending', async function () {
|
||||||
@ -50,7 +50,7 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
|
|||||||
it('cannot be finalized twice', async function () {
|
it('cannot be finalized twice', async function () {
|
||||||
await increaseTimeTo(this.afterEndTime)
|
await increaseTimeTo(this.afterEndTime)
|
||||||
await this.crowdsale.finalize({from: owner})
|
await this.crowdsale.finalize({from: owner})
|
||||||
await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('logs finalized', async function () {
|
it('logs finalized', async function () {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LimitBalanceMock = artifacts.require('helpers/LimitBalanceMock.sol');
|
var LimitBalanceMock = artifacts.require('helpers/LimitBalanceMock.sol');
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
|
|
||||||
contract('LimitBalance', function(accounts) {
|
contract('LimitBalance', function(accounts) {
|
||||||
let lb;
|
let lb;
|
||||||
@ -30,7 +30,7 @@ contract('LimitBalance', function(accounts) {
|
|||||||
await lb.limitedDeposit({value: amount});
|
await lb.limitedDeposit({value: amount});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ contract('LimitBalance', function(accounts) {
|
|||||||
await lb.limitedDeposit({value: amount+1});
|
await lb.limitedDeposit({value: amount+1});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
|
|
||||||
var Ownable = artifacts.require('../contracts/ownership/Ownable.sol');
|
var Ownable = artifacts.require('../contracts/ownership/Ownable.sol');
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ contract('Ownable', function(accounts) {
|
|||||||
await ownable.transferOwnership(other, {from: other});
|
await ownable.transferOwnership(other, {from: other});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ contract('Ownable', function(accounts) {
|
|||||||
await ownable.transferOwnership(null, {from: originalOwner});
|
await ownable.transferOwnership(null, {from: originalOwner});
|
||||||
assert.fail();
|
assert.fail();
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
const PausableMock = artifacts.require('helpers/PausableMock.sol');
|
const PausableMock = artifacts.require('helpers/PausableMock.sol');
|
||||||
|
|
||||||
contract('Pausable', function(accounts) {
|
contract('Pausable', function(accounts) {
|
||||||
@ -25,7 +25,7 @@ contract('Pausable', function(accounts) {
|
|||||||
await Pausable.normalProcess();
|
await Pausable.normalProcess();
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
let count1 = await Pausable.count();
|
let count1 = await Pausable.count();
|
||||||
assert.equal(count1, 0);
|
assert.equal(count1, 0);
|
||||||
@ -38,7 +38,7 @@ contract('Pausable', function(accounts) {
|
|||||||
await Pausable.drasticMeasure();
|
await Pausable.drasticMeasure();
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
|
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
|
||||||
assert.isFalse(drasticMeasureTaken);
|
assert.isFalse(drasticMeasureTaken);
|
||||||
@ -71,7 +71,7 @@ contract('Pausable', function(accounts) {
|
|||||||
await Pausable.drasticMeasure();
|
await Pausable.drasticMeasure();
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
|
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'user strict';
|
'user strict';
|
||||||
|
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
var PausableTokenMock = artifacts.require('./helpers/PausableTokenMock.sol');
|
var PausableTokenMock = artifacts.require('./helpers/PausableTokenMock.sol');
|
||||||
|
|
||||||
contract('PausableToken', function(accounts) {
|
contract('PausableToken', function(accounts) {
|
||||||
@ -57,7 +57,7 @@ contract('PausableToken', function(accounts) {
|
|||||||
await token.transfer(accounts[1], 100);
|
await token.transfer(accounts[1], 100);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ contract('PausableToken', function(accounts) {
|
|||||||
await token.transferFrom(accounts[0], accounts[1], 100);
|
await token.transferFrom(accounts[0], accounts[1], 100);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@ -6,7 +6,7 @@ require('chai')
|
|||||||
.should()
|
.should()
|
||||||
|
|
||||||
import ether from './helpers/ether'
|
import ether from './helpers/ether'
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
|
|
||||||
const RefundVault = artifacts.require('RefundVault')
|
const RefundVault = artifacts.require('RefundVault')
|
||||||
|
|
||||||
@ -24,11 +24,11 @@ contract('RefundVault', function ([_, owner, wallet, investor]) {
|
|||||||
|
|
||||||
it('should not refund contribution during active state', async function () {
|
it('should not refund contribution during active state', async function () {
|
||||||
await this.vault.deposit(investor, {value, from: owner})
|
await this.vault.deposit(investor, {value, from: owner})
|
||||||
await this.vault.refund(investor).should.be.rejectedWith(EVMThrow)
|
await this.vault.refund(investor).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('only owner can enter refund mode', async function () {
|
it('only owner can enter refund mode', async function () {
|
||||||
await this.vault.enableRefunds({from: _}).should.be.rejectedWith(EVMThrow)
|
await this.vault.enableRefunds({from: _}).should.be.rejectedWith(EVMRevert)
|
||||||
await this.vault.enableRefunds({from: owner}).should.be.fulfilled
|
await this.vault.enableRefunds({from: owner}).should.be.fulfilled
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ contract('RefundVault', function ([_, owner, wallet, investor]) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('only owner can close', async function () {
|
it('only owner can close', async function () {
|
||||||
await this.vault.close({from: _}).should.be.rejectedWith(EVMThrow)
|
await this.vault.close({from: _}).should.be.rejectedWith(EVMRevert)
|
||||||
await this.vault.close({from: owner}).should.be.fulfilled
|
await this.vault.close({from: owner}).should.be.fulfilled
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import ether from './helpers/ether'
|
|||||||
import {advanceBlock} from './helpers/advanceToBlock'
|
import {advanceBlock} from './helpers/advanceToBlock'
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
||||||
import latestTime from './helpers/latestTime'
|
import latestTime from './helpers/latestTime'
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
|
|
||||||
const BigNumber = web3.BigNumber
|
const BigNumber = web3.BigNumber
|
||||||
|
|
||||||
@ -35,22 +35,22 @@ contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {
|
|||||||
describe('creating a valid crowdsale', function () {
|
describe('creating a valid crowdsale', function () {
|
||||||
|
|
||||||
it('should fail with zero goal', async function () {
|
it('should fail with zero goal', async function () {
|
||||||
await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, {from: owner}).should.be.rejectedWith(EVMThrow);
|
await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, {from: owner}).should.be.rejectedWith(EVMRevert);
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should deny refunds before end', async function () {
|
it('should deny refunds before end', async function () {
|
||||||
await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert)
|
||||||
await increaseTimeTo(this.startTime)
|
await increaseTimeTo(this.startTime)
|
||||||
await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should deny refunds after end if goal was reached', async function () {
|
it('should deny refunds after end if goal was reached', async function () {
|
||||||
await increaseTimeTo(this.startTime)
|
await increaseTimeTo(this.startTime)
|
||||||
await this.crowdsale.sendTransaction({value: goal, from: investor})
|
await this.crowdsale.sendTransaction({value: goal, from: investor})
|
||||||
await increaseTimeTo(this.afterEndTime)
|
await increaseTimeTo(this.afterEndTime)
|
||||||
await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMThrow)
|
await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should allow refunds after end if goal was not reached', async function () {
|
it('should allow refunds after end if goal was not reached', async function () {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertJump = require('./helpers/assertJump');
|
||||||
var SafeMathMock = artifacts.require("./helpers/SafeMathMock.sol");
|
var SafeMathMock = artifacts.require("./helpers/SafeMathMock.sol");
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ contract('SafeMath', function(accounts) {
|
|||||||
let add = await safeMath.add(a, b);
|
let add = await safeMath.add(a, b);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ contract('SafeMath', function(accounts) {
|
|||||||
let multiply = await safeMath.multiply(a, b);
|
let multiply = await safeMath.multiply(a, b);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import ether from './helpers/ether'
|
|||||||
import {advanceBlock} from './helpers/advanceToBlock'
|
import {advanceBlock} from './helpers/advanceToBlock'
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
import {increaseTimeTo, duration} from './helpers/increaseTime'
|
||||||
import latestTime from './helpers/latestTime'
|
import latestTime from './helpers/latestTime'
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
|
|
||||||
const BigNumber = web3.BigNumber;
|
const BigNumber = web3.BigNumber;
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not accept payments before start', async function () {
|
it('should not accept payments before start', async function () {
|
||||||
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMThrow);
|
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert);
|
||||||
await this.crowdsale.buyTokens(investor, {from: investor, value: ether(1)}).should.be.rejectedWith(EVMThrow);
|
await this.crowdsale.buyTokens(investor, {from: investor, value: ether(1)}).should.be.rejectedWith(EVMRevert);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept payments during the sale', async function () {
|
it('should accept payments during the sale', async function () {
|
||||||
@ -65,14 +65,14 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
|
|||||||
|
|
||||||
it('should reject payments after end', async function () {
|
it('should reject payments after end', async function () {
|
||||||
await increaseTimeTo(this.afterEnd);
|
await increaseTimeTo(this.afterEnd);
|
||||||
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMThrow);
|
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert);
|
||||||
await this.crowdsale.buyTokens(investor, {value: ether(1), from: investor}).should.be.rejectedWith(EVMThrow);
|
await this.crowdsale.buyTokens(investor, {value: ether(1), from: investor}).should.be.rejectedWith(EVMRevert);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reject payments over cap', async function () {
|
it('should reject payments over cap', async function () {
|
||||||
await increaseTimeTo(this.startTime);
|
await increaseTimeTo(this.startTime);
|
||||||
await this.crowdsale.send(CAP);
|
await this.crowdsale.send(CAP);
|
||||||
await this.crowdsale.send(1).should.be.rejectedWith(EVMThrow);
|
await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow finalization and transfer funds to wallet if the goal is reached', async function () {
|
it('should allow finalization and transfer funds to wallet if the goal is reached', async function () {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assertJump = require('./helpers/assertJump');
|
const assertRevert = require('./helpers/assertRevert');
|
||||||
const expectThrow = require('./helpers/expectThrow');
|
const expectThrow = require('./helpers/expectThrow');
|
||||||
var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol');
|
var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol');
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ contract('StandardToken', function(accounts) {
|
|||||||
await token.transfer(accounts[1], 101);
|
await token.transfer(accounts[1], 101);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ contract('StandardToken', function(accounts) {
|
|||||||
await token.transferFrom(accounts[0], accounts[2], 100, {from: accounts[1]});
|
await token.transferFrom(accounts[0], accounts[2], 100, {from: accounts[1]});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ contract('StandardToken', function(accounts) {
|
|||||||
await token.transferFrom(accounts[0], accounts[2], balance0+1, {from: accounts[1]});
|
await token.transferFrom(accounts[0], accounts[2], balance0+1, {from: accounts[1]});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ contract('StandardToken', function(accounts) {
|
|||||||
let transfer = await token.transfer(0x0, 100);
|
let transfer = await token.transfer(0x0, 100);
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ contract('StandardToken', function(accounts) {
|
|||||||
let transfer = await token.transferFrom(accounts[0], 0x0, 100, {from: accounts[1]});
|
let transfer = await token.transferFrom(accounts[0], 0x0, 100, {from: accounts[1]});
|
||||||
assert.fail('should have thrown before');
|
assert.fail('should have thrown before');
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
assertJump(error);
|
assertRevert(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ require('chai')
|
|||||||
.use(require('chai-bignumber')(BigNumber))
|
.use(require('chai-bignumber')(BigNumber))
|
||||||
.should();
|
.should();
|
||||||
|
|
||||||
import EVMThrow from './helpers/EVMThrow'
|
import EVMRevert from './helpers/EVMRevert'
|
||||||
import latestTime from './helpers/latestTime';
|
import latestTime from './helpers/latestTime';
|
||||||
import {increaseTimeTo, duration} from './helpers/increaseTime';
|
import {increaseTimeTo, duration} from './helpers/increaseTime';
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('cannot be released before cliff', async function () {
|
it('cannot be released before cliff', async function () {
|
||||||
await this.vesting.release(this.token.address).should.be.rejectedWith(EVMThrow);
|
await this.vesting.release(this.token.address).should.be.rejectedWith(EVMRevert);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be released after cliff', async function () {
|
it('can be released after cliff', async function () {
|
||||||
@ -76,7 +76,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
|
|||||||
|
|
||||||
it('should fail to be revoked by owner if revocable not set', async function () {
|
it('should fail to be revoked by owner if revocable not set', async function () {
|
||||||
const vesting = await TokenVesting.new(beneficiary, this.start, this.cliff, this.duration, false, { from: owner } );
|
const vesting = await TokenVesting.new(beneficiary, this.start, this.cliff, this.duration, false, { from: owner } );
|
||||||
await vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMThrow);
|
await vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the non-vested tokens when revoked by owner', async function () {
|
it('should return the non-vested tokens when revoked by owner', async function () {
|
||||||
@ -109,7 +109,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
|
|||||||
|
|
||||||
await this.vesting.revoke(this.token.address, { from: owner });
|
await this.vesting.revoke(this.token.address, { from: owner });
|
||||||
|
|
||||||
await this.vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMThrow);
|
await this.vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
1
test/helpers/EVMRevert.js
Normal file
1
test/helpers/EVMRevert.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default 'revert'
|
||||||
3
test/helpers/assertRevert.js
Normal file
3
test/helpers/assertRevert.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function(error) {
|
||||||
|
assert.isAbove(error.message.search('revert'), -1, 'Error containing "revert" must be returned');
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user