Update to testrpc 6.0.1 and test fixes for revert opcode.

pull/378/merge
Ben Burns 7 years ago committed by Alejandro Santander
parent b9cbea1c9c
commit c29dd086d3
  1. 6
      package-lock.json
  2. 2
      package.json
  3. 6
      test/BasicToken.js
  4. 4
      test/BurnableToken.js
  5. 8
      test/CappedCrowdsale.js
  6. 6
      test/Claimable.js
  7. 2
      test/Contactable.js
  8. 10
      test/Crowdsale.js
  9. 10
      test/DayLimit.js
  10. 4
      test/DelayedClaimble.js
  11. 8
      test/FinalizableCrowdsale.js
  12. 6
      test/LimitBalance.js
  13. 6
      test/Ownable.js
  14. 8
      test/Pausable.js
  15. 6
      test/PausableToken.js
  16. 8
      test/RefundVault.js
  17. 10
      test/RefundableCrowdsale.js
  18. 5
      test/SafeMath.js
  19. 12
      test/SampleCrowdsale.js
  20. 12
      test/StandardToken.js
  21. 8
      test/TokenVesting.js
  22. 1
      test/helpers/EVMRevert.js
  23. 3
      test/helpers/assertRevert.js

6
package-lock.json generated

@ -2100,9 +2100,9 @@
}
},
"ethereumjs-testrpc": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ethereumjs-testrpc/-/ethereumjs-testrpc-4.1.1.tgz",
"integrity": "sha512-NQjL/5chwWVjCOzVfsExdkw2yN+atFPGUVfxhyCh27fLBREcK0X2KU72b2kLaqkd4nIEjd68+O3zMtExzf43+w==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/ethereumjs-testrpc/-/ethereumjs-testrpc-6.0.1.tgz",
"integrity": "sha1-CdoVoUox2jhPsQwIwPqaxXasgTc=",
"dev": true,
"requires": {
"webpack": "3.5.4"

@ -36,7 +36,7 @@
"chai-bignumber": "^2.0.0",
"coveralls": "^2.13.1",
"ethereumjs-util": "^5.1.2",
"ethereumjs-testrpc": "^4.1.1",
"ethereumjs-testrpc": "^6.0.1",
"mocha-lcov-reporter": "^1.3.0",
"solidity-coverage": "^0.2.2",
"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");
@ -28,7 +28,7 @@ contract('BasicToken', function(accounts) {
let transfer = await token.transfer(accounts[1], 101);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});
@ -38,7 +38,7 @@ contract('BasicToken', function(accounts) {
let transfer = await token.transfer(0x0, 100);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});

@ -1,6 +1,6 @@
'use strict'
const EVMThrow = require('./helpers/EVMThrow.js')
const EVMRevert = require('./helpers/EVMRevert.js')
const BurnableTokenMock = artifacts.require("./helpers/BurnableTokenMock.sol")
const BigNumber = web3.BigNumber
@ -34,6 +34,6 @@ contract('BurnableToken', function (accounts) {
it('cannot burn more tokens than your balance', async function () {
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 {increaseTimeTo, duration} from './helpers/increaseTime'
import latestTime from './helpers/latestTime'
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
const BigNumber = web3.BigNumber
@ -38,7 +38,7 @@ 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).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 () {
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 () {
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';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
var Claimable = artifacts.require('../contracts/ownership/Claimable.sol');
@ -28,7 +28,7 @@ contract('Claimable', function(accounts) {
await claimable.claimOwnership({from: accounts[2]});
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});
@ -40,7 +40,7 @@ contract('Claimable', function(accounts) {
await claimable.transferOwnership(other, {from: other});
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});

@ -1,5 +1,5 @@
'use strict';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
var Contactable = artifacts.require('../contracts/ownership/Contactable.sol');

@ -2,7 +2,7 @@ import ether from './helpers/ether'
import {advanceBlock} from './helpers/advanceToBlock'
import {increaseTimeTo, duration} from './helpers/increaseTime'
import latestTime from './helpers/latestTime'
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
const BigNumber = web3.BigNumber
@ -53,8 +53,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
describe('accepting payments', function () {
it('should reject payments before start', async function () {
await this.crowdsale.send(value).should.be.rejectedWith(EVMThrow)
await this.crowdsale.buyTokens(investor, {from: purchaser, value: 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(EVMRevert)
})
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 () {
await increaseTimeTo(this.afterEndTime)
await this.crowdsale.send(value).should.be.rejectedWith(EVMThrow)
await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).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(EVMRevert)
})
})

@ -1,5 +1,5 @@
'use strict';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
import latestTime from './helpers/latestTime'
import {increaseTimeTo, duration} from './helpers/increaseTime'
@ -39,7 +39,7 @@ contract('DayLimit', function(accounts) {
await dayLimit.attemptSpend(3);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});
@ -52,7 +52,7 @@ contract('DayLimit', function(accounts) {
await dayLimit.attemptSpend(3);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);
@ -72,7 +72,7 @@ contract('DayLimit', function(accounts) {
await dayLimit.attemptSpend(3);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);
@ -95,7 +95,7 @@ contract('DayLimit', function(accounts) {
await dayLimit.attemptSpend(3);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);

@ -49,7 +49,7 @@ contract('DelayedClaimable', function(accounts) {
} catch (error) {
err = error;
}
assert.isFalse(err.message.search('invalid opcode') === -1);
assert.isFalse(err.message.search('revert') === -1);
let owner = await delayedClaimable.owner();
assert.isTrue(owner !== accounts[1]);
});
@ -62,7 +62,7 @@ contract('DelayedClaimable', function(accounts) {
} catch (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 {increaseTimeTo, duration} from './helpers/increaseTime'
import latestTime from './helpers/latestTime'
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
const BigNumber = web3.BigNumber
@ -34,12 +34,12 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
})
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 () {
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 () {
@ -50,7 +50,7 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {
it('cannot be finalized twice', async function () {
await increaseTimeTo(this.afterEndTime)
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 () {

@ -1,7 +1,7 @@
'use strict';
var LimitBalanceMock = artifacts.require('helpers/LimitBalanceMock.sol');
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
contract('LimitBalance', function(accounts) {
let lb;
@ -30,7 +30,7 @@ contract('LimitBalance', function(accounts) {
await lb.limitedDeposit({value: amount});
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});
@ -54,7 +54,7 @@ contract('LimitBalance', function(accounts) {
await lb.limitedDeposit({value: amount+1});
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});

@ -1,5 +1,5 @@
'use strict';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
var Ownable = artifacts.require('../contracts/ownership/Ownable.sol');
@ -31,7 +31,7 @@ contract('Ownable', function(accounts) {
await ownable.transferOwnership(other, {from: other});
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});
@ -41,7 +41,7 @@ contract('Ownable', function(accounts) {
await ownable.transferOwnership(null, {from: originalOwner});
assert.fail();
} catch(error) {
assertJump(error);
assertRevert(error);
}
});

@ -1,6 +1,6 @@
'use strict';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
const PausableMock = artifacts.require('helpers/PausableMock.sol');
contract('Pausable', function(accounts) {
@ -25,7 +25,7 @@ contract('Pausable', function(accounts) {
await Pausable.normalProcess();
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
let count1 = await Pausable.count();
assert.equal(count1, 0);
@ -38,7 +38,7 @@ contract('Pausable', function(accounts) {
await Pausable.drasticMeasure();
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
assert.isFalse(drasticMeasureTaken);
@ -71,7 +71,7 @@ contract('Pausable', function(accounts) {
await Pausable.drasticMeasure();
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();

@ -1,6 +1,6 @@
'user strict';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
var PausableTokenMock = artifacts.require('./helpers/PausableTokenMock.sol');
contract('PausableToken', function(accounts) {
@ -57,7 +57,7 @@ contract('PausableToken', function(accounts) {
await token.transfer(accounts[1], 100);
assert.fail('should have thrown before');
} catch (error) {
assertJump(error);
assertRevert(error);
}
});
@ -67,7 +67,7 @@ contract('PausableToken', function(accounts) {
await token.transferFrom(accounts[0], accounts[1], 100);
assert.fail('should have thrown before');
} catch (error) {
assertJump(error);
assertRevert(error);
}
});
})

@ -6,7 +6,7 @@ require('chai')
.should()
import ether from './helpers/ether'
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
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 () {
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 () {
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
})
@ -44,7 +44,7 @@ contract('RefundVault', function ([_, owner, wallet, investor]) {
})
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
})

@ -2,7 +2,7 @@ import ether from './helpers/ether'
import {advanceBlock} from './helpers/advanceToBlock'
import {increaseTimeTo, duration} from './helpers/increaseTime'
import latestTime from './helpers/latestTime'
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
const BigNumber = web3.BigNumber
@ -35,22 +35,22 @@ contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {
describe('creating a valid crowdsale', 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 () {
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 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 () {
await increaseTimeTo(this.startTime)
await this.crowdsale.sendTransaction({value: goal, from: investor})
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 () {

@ -1,3 +1,4 @@
const assertRevert = require('./helpers/assertRevert');
const assertJump = require('./helpers/assertJump');
var SafeMathMock = artifacts.require("./helpers/SafeMathMock.sol");
@ -53,7 +54,7 @@ contract('SafeMath', function(accounts) {
let add = await safeMath.add(a, b);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});
@ -64,7 +65,7 @@ contract('SafeMath', function(accounts) {
let multiply = await safeMath.multiply(a, b);
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});

@ -2,7 +2,7 @@ import ether from './helpers/ether'
import {advanceBlock} from './helpers/advanceToBlock'
import {increaseTimeTo, duration} from './helpers/increaseTime'
import latestTime from './helpers/latestTime'
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
const BigNumber = web3.BigNumber;
@ -48,8 +48,8 @@ contract('Crowdsale', function ([owner, wallet, investor]) {
});
it('should not accept payments before start', async function () {
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMThrow);
await this.crowdsale.buyTokens(investor, {from: investor, value: 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(EVMRevert);
});
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 () {
await increaseTimeTo(this.afterEnd);
await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMThrow);
await this.crowdsale.buyTokens(investor, {value: ether(1), from: investor}).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(EVMRevert);
});
it('should reject payments over cap', async function () {
await increaseTimeTo(this.startTime);
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 () {

@ -1,6 +1,6 @@
'use strict';
const assertJump = require('./helpers/assertJump');
const assertRevert = require('./helpers/assertRevert');
const expectThrow = require('./helpers/expectThrow');
var StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol');
@ -42,7 +42,7 @@ contract('StandardToken', function(accounts) {
await token.transfer(accounts[1], 101);
assert.fail('should have thrown before');
} 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]});
assert.fail('should have thrown before');
} 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]});
assert.fail('should have thrown before');
} catch (error) {
assertJump(error);
assertRevert(error);
}
});
@ -113,7 +113,7 @@ contract('StandardToken', function(accounts) {
let transfer = await token.transfer(0x0, 100);
assert.fail('should have thrown before');
} 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]});
assert.fail('should have thrown before');
} catch(error) {
assertJump(error);
assertRevert(error);
}
});

@ -5,7 +5,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
import EVMThrow from './helpers/EVMThrow'
import EVMRevert from './helpers/EVMRevert'
import latestTime from './helpers/latestTime';
import {increaseTimeTo, duration} from './helpers/increaseTime';
@ -29,7 +29,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
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 () {
@ -76,7 +76,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
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 } );
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 () {
@ -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 }).should.be.rejectedWith(EVMThrow);
await this.vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert);
});
});

@ -0,0 +1 @@
export default 'revert'

@ -0,0 +1,3 @@
module.exports = function(error) {
assert.isAbove(error.message.search('revert'), -1, 'Error containing "revert" must be returned');
}
Loading…
Cancel
Save