Improves Ownable events (#1397)
* signing prefix added * Minor improvement * Tests changed * Successfully tested * Minor improvements * Minor improvements * Revert "Dangling commas are now required. (#1359)" This reverts commita6889776f4. * updates * fixes #1392 * event tests added * constructor event added (cherry picked from commitaf42c39e6c)
This commit is contained in:
@ -9,8 +9,6 @@ pragma solidity ^0.4.24;
|
||||
contract Ownable {
|
||||
address private _owner;
|
||||
|
||||
|
||||
event OwnershipRenounced(address indexed previousOwner);
|
||||
event OwnershipTransferred(
|
||||
address indexed previousOwner,
|
||||
address indexed newOwner
|
||||
@ -23,6 +21,7 @@ contract Ownable {
|
||||
*/
|
||||
constructor() public {
|
||||
_owner = msg.sender;
|
||||
emit OwnershipTransferred(address(0), _owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +53,7 @@ contract Ownable {
|
||||
* modifier anymore.
|
||||
*/
|
||||
function renounceOwnership() public onlyOwner {
|
||||
emit OwnershipRenounced(_owner);
|
||||
emit OwnershipTransferred(_owner, address(0));
|
||||
_owner = address(0);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
const { expectThrow } = require('../helpers/expectThrow');
|
||||
const { EVMRevert } = require('../helpers/EVMRevert');
|
||||
const expectEvent = require('../helpers/expectEvent');
|
||||
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
|
||||
@ -14,7 +15,8 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {
|
||||
|
||||
it('changes owner after transfer', async function () {
|
||||
(await this.ownable.isOwner({ from: anyone })).should.be.equal(false);
|
||||
await this.ownable.transferOwnership(anyone, { from: owner });
|
||||
const { logs } = await this.ownable.transferOwnership(anyone, { from: owner });
|
||||
expectEvent.inLogs(logs, 'OwnershipTransferred');
|
||||
|
||||
(await this.ownable.owner()).should.equal(anyone);
|
||||
(await this.ownable.isOwner({ from: anyone })).should.be.equal(true);
|
||||
@ -29,7 +31,9 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {
|
||||
});
|
||||
|
||||
it('loses owner after renouncement', async function () {
|
||||
await this.ownable.renounceOwnership({ from: owner });
|
||||
const { logs } = await this.ownable.renounceOwnership({ from: owner });
|
||||
expectEvent.inLogs(logs, 'OwnershipTransferred');
|
||||
|
||||
(await this.ownable.owner()).should.equal(ZERO_ADDRESS);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user