Files
openzeppelin-contracts/test/ownership/DelayedClaimable.test.js
Nicolás Venturo 4544df47da 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.
2018-08-02 16:55:31 -03:00

48 lines
2.1 KiB
JavaScript

const { assertRevert } = require('../helpers/assertRevert');
const DelayedClaimable = artifacts.require('DelayedClaimable');
contract('DelayedClaimable', function ([_, owner, newOwner]) {
beforeEach(async function () {
this.delayedClaimable = await DelayedClaimable.new({ from: owner });
});
it('can set claim blocks', async function () {
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);
});
it('changes pendingOwner after transfer successful', async function () {
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);
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(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);
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(newOwner, { from: owner });
await assertRevert(this.delayedClaimable.setLimits(1001, 1000, { from: owner }));
});
});