Add guard to ERC20Migrator migrate function (#1659)

* Add guard to ERC20Migrator migrate function

* Add tests for premature migration in ERC20Migrator

These tests apply to the new guard condition, but they don't
fail without it, since the functions revert anyway.
They are added for completeness and to ensure full code coverage.

* Use context block around premature migration tests

We should use context blocks for situational details
and describe for features or functions.
This commit is contained in:
nikeshnazareth
2019-03-03 02:36:36 +11:00
committed by Nicolás Venturo
parent 7f54542172
commit 3772233cf5
2 changed files with 35 additions and 0 deletions

View File

@ -82,6 +82,7 @@ contract ERC20Migrator {
* @param amount amount of tokens to be migrated
*/
function migrate(address account, uint256 amount) public {
require(address(_newToken) != address(0));
_legacyToken.safeTransferFrom(account, address(this), amount);
_newToken.mint(account, amount);
}