Skip to content

Commit

Permalink
Test refactoring and explicit revert reasons (#45)
Browse files Browse the repository at this point in the history
* Test refactoring and check emitted events

Simplified and rewritten to use checked reverts

Added functions for verifying events emitted by a transaction

Cherry-picked from #25

Remove leading underscore in event params

Additional event parameters

Framework for event checking and TokenManager test impl

Check AccessList constructor events using new system

Linting

Typo

Explicit reasons and events for ExternalERC20Storage test

remove TODO

Linting

Check events emitted from upgrade function

Group whitelist/blacklist adding commands

Use non-blacklisted account for blacklist test

Simplify tests and remove rendundants

* Check remaining revert reasons and add missing cases

* Reinstate gas reporting

* Use built-in node assert for code preconditions
  • Loading branch information
truls authored and peteremiljensen committed Jan 7, 2019
1 parent 883b47c commit fd1c7aa
Show file tree
Hide file tree
Showing 13 changed files with 532 additions and 372 deletions.
14 changes: 8 additions & 6 deletions contracts/TokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ contract TokenManager is Ownable {
mapping (bytes32 => TokenEntry) private tokens;
bytes32[] private names;

event TokenAdded(bytes32 _name);
event TokenDeleted(bytes32 _name);
event TokenUpgraded(bytes32 _name);
event TokenAdded(bytes32 name, ITokenX addr);
event TokenDeleted(bytes32 name, ITokenX addr);
event TokenUpgraded(bytes32 name, ITokenX from, ITokenX to);

/**
* @dev Require that the token _name exists
Expand Down Expand Up @@ -70,7 +70,7 @@ contract TokenManager is Ownable {
exists: true
});
names.push(_name);
emit TokenAdded(_name);
emit TokenAdded(_name, _iTokenX);
}

/**
Expand All @@ -82,10 +82,11 @@ contract TokenManager is Ownable {
onlyOwner
tokenExists(_name)
{
ITokenX prev = tokens[_name].token;
delete names[tokens[_name].index];
delete tokens[_name].token;
delete tokens[_name];
emit TokenDeleted(_name);
emit TokenDeleted(_name, prev);
}

/**
Expand All @@ -99,8 +100,9 @@ contract TokenManager is Ownable {
tokenExists(_name)
notNullToken(_iTokenX)
{
ITokenX prev = tokens[_name].token;
tokens[_name].token = _iTokenX;
emit TokenUpgraded(_name);
emit TokenUpgraded(_name, prev, _iTokenX);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/ExternalERC20Storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ contract ExternalERC20Storage is Ownable {
onlyImplementorOrOwner
{
require(newImplementor != _implementor,
"Cannot transfer to same implementor as existsing");
"Cannot transfer to same implementor as existing");
address curImplementor = _implementor;
_implementor = newImplementor;
emit StorageImplementorTransferred(curImplementor, newImplementor);
Expand Down
21 changes: 21 additions & 0 deletions test/Accesslist.events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const utils = require('./utils.js');

module.exports = utils.makeEventMap({
// TODO: Implement the constructor using an inheritance system
constructor: (addr) => [{ eventName: 'OwnershipTransferred',
paramMap: { previousOwner: utils.ZERO_ADDRESS,
newOwner: addr } },
{ eventName: 'WhitelistAdminAdded',
paramMap: { account: addr } },
{ eventName: 'BlacklistAdminAdded',
paramMap: { account: addr } }
],
addWhitelisted: (addr) => [{ eventName: 'WhitelistAdded',
paramMap: { account: addr } }],
removeWhitelisted: (addr) => [{ eventName: 'WhitelistRemoved',
paramMap: { account: addr } }],
addBlacklisted: (addr) => [{ eventName: 'BlacklistAdded',
paramMap: { account: addr } }],
removeBlacklisted: (addr) => [{ eventName: 'BlacklistRemoved',
paramMap: { account: addr } }]
});
Loading

0 comments on commit fd1c7aa

Please sign in to comment.