Migration to truffle 5 (and web3 1.0 (and BN)) (#1601)
* Now compiling using truffle 5.
* Migrated some test files, missing BN scientific notation usage.
* Now using BN time values.
* Migrate ERC20 tests.
* Migrate all ERC20 tests.
* Migrate utils, payment and ownership tests.
* All tests save ERC721 migrated.
* Migrated ERC721 tests.
* Fix lint errors.
* Delete old test helpers.
* Fix remaining crowdsale tests.
* Fix signature bouncer tests.
* Update how constants is used.
* Compile script pre-removes the build dir.
* Fix SafeMath tests.
* Revert "Compile script pre-removes the build dir."
This reverts commit 247e745113.
* Fix linter errors.
* Upgrade openzeppelin-test-helpers dependency.
* Update openzeppelin-test-helpers dependency.
* Define math constants globally.
* Remove unnecessary ether unit.
* Roll back reduced ether amounts in tests.
* Remove unnecessary toNumber conversions.
* Delete compile script.
* Fixed failing test.
This commit is contained in:
@ -1,14 +1,12 @@
|
||||
const shouldFail = require('../helpers/shouldFail');
|
||||
const { ZERO_ADDRESS } = require('../helpers/constants');
|
||||
const { BN, constants, shouldFail } = require('openzeppelin-test-helpers');
|
||||
const { ZERO_ADDRESS } = constants;
|
||||
|
||||
const ERC20Mock = artifacts.require('ERC20Mock');
|
||||
const ERC20Mintable = artifacts.require('ERC20Mintable');
|
||||
const ERC20Migrator = artifacts.require('ERC20Migrator');
|
||||
|
||||
require('../helpers/setup');
|
||||
|
||||
contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
const totalSupply = 200;
|
||||
const totalSupply = new BN('200');
|
||||
|
||||
it('reverts with a null legacy token address', async function () {
|
||||
await shouldFail.reverting(ERC20Migrator.new(ZERO_ADDRESS));
|
||||
@ -81,7 +79,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
currentBurnedBalance.should.be.bignumber.equal(amount);
|
||||
|
||||
const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner);
|
||||
currentLegacyTokenBalance.should.be.bignumber.equal(0);
|
||||
currentLegacyTokenBalance.should.be.bignumber.equal('0');
|
||||
});
|
||||
|
||||
it('updates the total supply', async function () {
|
||||
@ -91,7 +89,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
});
|
||||
|
||||
describe('when the approved balance is lower than the owned balance', function () {
|
||||
const amount = baseAmount - 1;
|
||||
const amount = baseAmount.subn(1);
|
||||
|
||||
beforeEach('approving part of the balance to the new contract', async function () {
|
||||
await this.legacyToken.approve(this.migrator.address, amount, { from: owner });
|
||||
@ -106,7 +104,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
});
|
||||
|
||||
describe('migrate', function () {
|
||||
const baseAmount = 50;
|
||||
const baseAmount = new BN(50);
|
||||
|
||||
beforeEach('approving tokens to the new contract', async function () {
|
||||
await this.legacyToken.approve(this.migrator.address, baseAmount, { from: owner });
|
||||
@ -129,7 +127,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
currentBurnedBalance.should.be.bignumber.equal(amount);
|
||||
|
||||
const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner);
|
||||
currentLegacyTokenBalance.should.be.bignumber.equal(totalSupply - amount);
|
||||
currentLegacyTokenBalance.should.be.bignumber.equal(totalSupply.sub(amount));
|
||||
});
|
||||
|
||||
it('updates the total supply', async function () {
|
||||
@ -139,7 +137,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
});
|
||||
|
||||
describe('when the given amount is higher than the one approved', function () {
|
||||
const amount = baseAmount + 1;
|
||||
const amount = baseAmount.addn(1);
|
||||
|
||||
it('reverts', async function () {
|
||||
await shouldFail.reverting(this.migrator.migrate(owner, amount));
|
||||
|
||||
Reference in New Issue
Block a user