All tests now use account names, and dont use accounts[0] (except ERC… (#1137)

* All tests now use account names, and dont use accounts[0] (except ERC721)

* Added account names to some missing contracts.
This commit is contained in:
Nicolás Venturo
2018-08-02 16:55:31 -03:00
committed by GitHub
parent f49721576f
commit 4544df47da
41 changed files with 210 additions and 300 deletions

View File

@ -2,14 +2,14 @@ const { assertRevert } = require('../helpers/assertRevert');
const DelayedClaimable = artifacts.require('DelayedClaimable');
contract('DelayedClaimable', function (accounts) {
contract('DelayedClaimable', function ([_, owner, newOwner]) {
beforeEach(async function () {
this.delayedClaimable = await DelayedClaimable.new();
this.delayedClaimable = await DelayedClaimable.new({ from: owner });
});
it('can set claim blocks', async function () {
await this.delayedClaimable.transferOwnership(accounts[2]);
await this.delayedClaimable.setLimits(0, 1000);
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(0, 1000, { from: owner });
const end = await this.delayedClaimable.end();
assert.equal(end, 1000);
const start = await this.delayedClaimable.start();
@ -17,35 +17,31 @@ contract('DelayedClaimable', function (accounts) {
});
it('changes pendingOwner after transfer successful', async function () {
await this.delayedClaimable.transferOwnership(accounts[2]);
await this.delayedClaimable.setLimits(0, 1000);
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(0, 1000, { from: owner });
const end = await this.delayedClaimable.end();
assert.equal(end, 1000);
const start = await this.delayedClaimable.start();
assert.equal(start, 0);
const pendingOwner = await this.delayedClaimable.pendingOwner();
assert.equal(pendingOwner, accounts[2]);
await this.delayedClaimable.claimOwnership({ from: accounts[2] });
const owner = await this.delayedClaimable.owner();
assert.equal(owner, accounts[2]);
assert.equal((await this.delayedClaimable.pendingOwner()), newOwner);
await this.delayedClaimable.claimOwnership({ from: newOwner });
assert.equal((await this.delayedClaimable.owner()), newOwner);
});
it('changes pendingOwner after transfer fails', async function () {
await this.delayedClaimable.transferOwnership(accounts[1]);
await this.delayedClaimable.setLimits(100, 110);
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(100, 110, { from: owner });
const end = await this.delayedClaimable.end();
assert.equal(end, 110);
const start = await this.delayedClaimable.start();
assert.equal(start, 100);
const pendingOwner = await this.delayedClaimable.pendingOwner();
assert.equal(pendingOwner, accounts[1]);
await assertRevert(this.delayedClaimable.claimOwnership({ from: accounts[1] }));
const owner = await this.delayedClaimable.owner();
assert.isTrue(owner !== accounts[1]);
assert.equal((await this.delayedClaimable.pendingOwner()), newOwner);
await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner }));
assert.isTrue((await this.delayedClaimable.owner()) !== newOwner);
});
it('set end and start invalid values fail', async function () {
await this.delayedClaimable.transferOwnership(accounts[1]);
await assertRevert(this.delayedClaimable.setLimits(1001, 1000));
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await assertRevert(this.delayedClaimable.setLimits(1001, 1000, { from: owner }));
});
});