parent
f2142545c7
commit
688106e9c3
@ -1,46 +1,53 @@ |
||||
contract('Claimable', function(accounts) { |
||||
var claimable; |
||||
let claimable; |
||||
|
||||
beforeEach(async function() { |
||||
beforeEach(async function(done) { |
||||
claimable = await Claimable.new(); |
||||
done(); |
||||
}); |
||||
|
||||
it("should have an owner", async function() { |
||||
it("should have an owner", async function(done) { |
||||
let owner = await claimable.owner(); |
||||
assert.isTrue(owner != 0); |
||||
done(); |
||||
}); |
||||
|
||||
it("changes pendingOwner after transfer", async function() { |
||||
it("changes pendingOwner after transfer", async function(done) { |
||||
let newOwner = accounts[1]; |
||||
let transfer = await claimable.transfer(newOwner); |
||||
let pendingOwner = await claimable.pendingOwner(); |
||||
assert.isTrue(pendingOwner === newOwner); |
||||
done(); |
||||
}); |
||||
|
||||
it("should prevent to claimOwnership from no pendingOwner", async function() { |
||||
it("should prevent to claimOwnership from no pendingOwner", async function(done) { |
||||
let claimedOwner = await claimable.claimOwnership({from: accounts[2]}); |
||||
let owner = await claimable.owner(); |
||||
assert.isTrue(owner != accounts[2]); |
||||
done(); |
||||
}); |
||||
|
||||
it("should prevent non-owners from transfering", async function() { |
||||
it("should prevent non-owners from transfering", async function(done) { |
||||
let transfer = await claimable.transfer(accounts[2], {from: accounts[2]}); |
||||
let pendingOwner = await claimable.pendingOwner(); |
||||
assert.isFalse(pendingOwner === accounts[2]); |
||||
done(); |
||||
}); |
||||
|
||||
describe("after initiating a transfer", function () { |
||||
let newOwner; |
||||
|
||||
beforeEach(function () { |
||||
beforeEach(async function (done) { |
||||
newOwner = accounts[1]; |
||||
return claimable.transfer(newOwner); |
||||
await claimable.transfer(newOwner); |
||||
done(); |
||||
}); |
||||
|
||||
it("changes allow pending owner to claim ownership", async function() { |
||||
it("changes allow pending owner to claim ownership", async function(done) { |
||||
let claimedOwner = await claimable.claimOwnership({from: newOwner}) |
||||
let owner = await claimable.owner(); |
||||
assert.isTrue(owner === newOwner); |
||||
done(); |
||||
}); |
||||
}); |
||||
}); |
||||
|
@ -1,35 +1,40 @@ |
||||
contract('Ownable', function(accounts) { |
||||
var ownable; |
||||
let ownable; |
||||
|
||||
beforeEach(async function() { |
||||
beforeEach(async function(done) { |
||||
ownable = await Ownable.new(); |
||||
done(); |
||||
}); |
||||
|
||||
it("should have an owner", async function() { |
||||
it("should have an owner", async function(done) { |
||||
let owner = await ownable.owner(); |
||||
assert.isTrue(owner != 0); |
||||
done(); |
||||
}); |
||||
|
||||
it("changes owner after transfer", async function() { |
||||
it("changes owner after transfer", async function(done) { |
||||
let other = accounts[1]; |
||||
let transfer = await ownable.transfer(other); |
||||
let owner = await ownable.owner(); |
||||
assert.isTrue(owner === other); |
||||
done(); |
||||
}); |
||||
|
||||
it("should prevent non-owners from transfering", async function() { |
||||
it("should prevent non-owners from transfering", async function(done) { |
||||
let other = accounts[2]; |
||||
let transfer = await ownable.transfer(other, {from: accounts[2]}); |
||||
let owner = await ownable.owner(); |
||||
assert.isFalse(owner === other); |
||||
done(); |
||||
}); |
||||
|
||||
it("should guard ownership against stuck state", async function() { |
||||
it("should guard ownership against stuck state", async function(done) { |
||||
let ownable = Ownable.deployed(); |
||||
let originalOwner = await ownable.owner(); |
||||
let transfer = await ownable.transfer(null, {from: originalOwner}); |
||||
let newOwner = await ownable.owner(); |
||||
assert.equal(originalOwner, newOwner); |
||||
done(); |
||||
}); |
||||
|
||||
}); |
||||
|
Loading…
Reference in new issue