Skip to content

Commit

Permalink
test: add additional unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vbidin committed Jul 3, 2024
1 parent d5de4d8 commit a8509cf
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Migrator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ contract MigratorTest is Test {
address account = makeAddr("account");
address operationalAdmin = makeAddr("operationalAdmin");
address recipient = makeAddr("recipient");
address sender = makeAddr("sender");

uint256 amount = 100e18;

Migrator internal _migrator;
MockERC20 internal _oldToken;
Expand Down Expand Up @@ -159,6 +162,32 @@ contract MigratorTest is Test {
_migrator.migrate(1);
}

function test_migrate_recipient() external {
_oldToken.mint(address(sender), amount);

vm.prank(sender);
_oldToken.approve(address(_migrator), amount);

assertEq(_oldToken.balanceOf(address(sender)), amount);
assertEq(_oldToken.balanceOf(address(_migrator)), 0);
assertEq(_oldToken.balanceOf(address(recipient)), 0);

assertEq(_newToken.balanceOf(address(sender)), 0);
assertEq(_newToken.balanceOf(address(_migrator)), OLD_SUPPLY * SCALAR);
assertEq(_newToken.balanceOf(address(recipient)), 0);

vm.prank(sender);
_migrator.migrate(address(recipient), amount);

assertEq(_oldToken.balanceOf(address(sender)), 0);
assertEq(_oldToken.balanceOf(address(_migrator)), amount);
assertEq(_oldToken.balanceOf(address(recipient)), 0);

assertEq(_newToken.balanceOf(address(sender)), 0);
assertEq(_newToken.balanceOf(address(_migrator)), (OLD_SUPPLY - amount) * SCALAR);
assertEq(_newToken.balanceOf(address(recipient)), amount * SCALAR);
}

function testFuzz_migrate_insufficientApproval(uint256 amount_) external {
amount_ = bound(amount_, 1, OLD_SUPPLY);

Expand Down

0 comments on commit a8509cf

Please sign in to comment.