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,8 +1,5 @@
|
||||
require('../../helpers/setup');
|
||||
const { ZERO_ADDRESS } = require('../../helpers/constants');
|
||||
const expectEvent = require('../../helpers/expectEvent');
|
||||
const send = require('../../helpers/send');
|
||||
const shouldFail = require('../../helpers/shouldFail');
|
||||
const { BN, constants, expectEvent, shouldFail } = require('openzeppelin-test-helpers');
|
||||
const { ZERO_ADDRESS } = constants;
|
||||
|
||||
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
|
||||
const ERC721Mock = artifacts.require('ERC721Mock.sol');
|
||||
@ -15,7 +12,7 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
shouldBehaveLikeERC721(creator, creator, accounts);
|
||||
|
||||
describe('internal functions', function () {
|
||||
const tokenId = 5042;
|
||||
const tokenId = new BN('5042');
|
||||
|
||||
describe('_mint(address, uint256)', function () {
|
||||
it('reverts with a null destination address', async function () {
|
||||
@ -32,7 +29,7 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
});
|
||||
|
||||
it('creates the token', async function () {
|
||||
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal(1);
|
||||
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('1');
|
||||
(await this.token.ownerOf(tokenId)).should.equal(tokenOwner);
|
||||
});
|
||||
|
||||
@ -44,7 +41,7 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
|
||||
describe('_burn(address, uint256)', function () {
|
||||
it('reverts when burning a non-existent token id', async function () {
|
||||
await shouldFail.reverting(send.transaction(this.token, 'burn', 'address,uint256', [tokenOwner, tokenId]));
|
||||
await shouldFail.reverting(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId));
|
||||
});
|
||||
|
||||
context('with minted token', function () {
|
||||
@ -53,13 +50,12 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
});
|
||||
|
||||
it('reverts when the account is not the owner', async function () {
|
||||
await shouldFail.reverting(send.transaction(this.token, 'burn', 'address,uint256', [anyone, tokenId]));
|
||||
await shouldFail.reverting(this.token.methods['burn(address,uint256)'](anyone, tokenId));
|
||||
});
|
||||
|
||||
context('with burnt token', function () {
|
||||
beforeEach(async function () {
|
||||
({ logs: this.logs } =
|
||||
await send.transaction(this.token, 'burn', 'address,uint256', [tokenOwner, tokenId]));
|
||||
({ logs: this.logs } = await this.token.methods['burn(address,uint256)'](tokenOwner, tokenId));
|
||||
});
|
||||
|
||||
it('emits a Transfer event', function () {
|
||||
@ -67,12 +63,12 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
});
|
||||
|
||||
it('deletes the token', async function () {
|
||||
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal(0);
|
||||
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0');
|
||||
await shouldFail.reverting(this.token.ownerOf(tokenId));
|
||||
});
|
||||
|
||||
it('reverts when burning a token id that has been deleted', async function () {
|
||||
await shouldFail.reverting(send.transaction(this.token, 'burn', 'address,uint256', [tokenOwner, tokenId]));
|
||||
await shouldFail.reverting(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId));
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -80,7 +76,7 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
|
||||
describe('_burn(uint256)', function () {
|
||||
it('reverts when burning a non-existent token id', async function () {
|
||||
await shouldFail.reverting(send.transaction(this.token, 'burn', 'uint256', [tokenId]));
|
||||
await shouldFail.reverting(this.token.methods['burn(uint256)'](tokenId));
|
||||
});
|
||||
|
||||
context('with minted token', function () {
|
||||
@ -90,7 +86,7 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
|
||||
context('with burnt token', function () {
|
||||
beforeEach(async function () {
|
||||
({ logs: this.logs } = await send.transaction(this.token, 'burn', 'uint256', [tokenId]));
|
||||
({ logs: this.logs } = await this.token.methods['burn(uint256)'](tokenId));
|
||||
});
|
||||
|
||||
it('emits a Transfer event', function () {
|
||||
@ -98,12 +94,12 @@ contract('ERC721', function ([_, creator, tokenOwner, anyone, ...accounts]) {
|
||||
});
|
||||
|
||||
it('deletes the token', async function () {
|
||||
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal(0);
|
||||
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0');
|
||||
await shouldFail.reverting(this.token.ownerOf(tokenId));
|
||||
});
|
||||
|
||||
it('reverts when burning a token id that has been deleted', async function () {
|
||||
await shouldFail.reverting(send.transaction(this.token, 'burn', 'uint256', [tokenId]));
|
||||
await shouldFail.reverting(this.token.methods['burn(uint256)'](tokenId));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user