You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
8 years ago
|
|
||
|
var DelayedClaimable = artifacts.require('../contracts/ownership/DelayedClaimable.sol');
|
||
|
|
||
7 years ago
|
contract('DelayedClaimable', function (accounts) {
|
||
8 years ago
|
var delayedClaimable;
|
||
|
|
||
7 years ago
|
beforeEach(function () {
|
||
|
return DelayedClaimable.new().then(function (deployed) {
|
||
8 years ago
|
delayedClaimable = deployed;
|
||
|
});
|
||
|
});
|
||
|
|
||
7 years ago
|
it('can set claim blocks', async function () {
|
||
8 years ago
|
await delayedClaimable.transferOwnership(accounts[2]);
|
||
|
await delayedClaimable.setLimits(0, 1000);
|
||
|
let end = await delayedClaimable.end();
|
||
|
assert.equal(end, 1000);
|
||
|
let start = await delayedClaimable.start();
|
||
|
assert.equal(start, 0);
|
||
|
});
|
||
|
|
||
7 years ago
|
it('changes pendingOwner after transfer successful', async function () {
|
||
8 years ago
|
await delayedClaimable.transferOwnership(accounts[2]);
|
||
|
await delayedClaimable.setLimits(0, 1000);
|
||
|
let end = await delayedClaimable.end();
|
||
|
assert.equal(end, 1000);
|
||
|
let start = await delayedClaimable.start();
|
||
|
assert.equal(start, 0);
|
||
|
let pendingOwner = await delayedClaimable.pendingOwner();
|
||
|
assert.equal(pendingOwner, accounts[2]);
|
||
7 years ago
|
await delayedClaimable.claimOwnership({ from: accounts[2] });
|
||
8 years ago
|
let owner = await delayedClaimable.owner();
|
||
|
assert.equal(owner, accounts[2]);
|
||
8 years ago
|
});
|
||
|
|
||
7 years ago
|
it('changes pendingOwner after transfer fails', async function () {
|
||
8 years ago
|
await delayedClaimable.transferOwnership(accounts[1]);
|
||
|
await delayedClaimable.setLimits(100, 110);
|
||
|
let end = await delayedClaimable.end();
|
||
|
assert.equal(end, 110);
|
||
|
let start = await delayedClaimable.start();
|
||
|
assert.equal(start, 100);
|
||
|
let pendingOwner = await delayedClaimable.pendingOwner();
|
||
|
assert.equal(pendingOwner, accounts[1]);
|
||
|
var err = null;
|
||
|
try {
|
||
7 years ago
|
await delayedClaimable.claimOwnership({ from: accounts[1] });
|
||
8 years ago
|
} catch (error) {
|
||
|
err = error;
|
||
|
}
|
||
7 years ago
|
assert.isFalse(err.message.search('revert') === -1);
|
||
8 years ago
|
let owner = await delayedClaimable.owner();
|
||
|
assert.isTrue(owner !== accounts[1]);
|
||
8 years ago
|
});
|
||
|
|
||
7 years ago
|
it('set end and start invalid values fail', async function () {
|
||
8 years ago
|
await delayedClaimable.transferOwnership(accounts[1]);
|
||
|
var err = null;
|
||
|
try {
|
||
|
await delayedClaimable.setLimits(1001, 1000);
|
||
|
} catch (error) {
|
||
|
err = error;
|
||
|
}
|
||
7 years ago
|
assert.isFalse(err.message.search('revert') === -1);
|
||
8 years ago
|
});
|
||
|
});
|