Skip to content

Commit

Permalink
test: add unmigration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
QEDK committed Aug 6, 2023
1 parent 6f14996 commit c48a185
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/PolygonMigration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,29 @@ contract PolygonMigrationTest is Test {
migration.migrate(amount);

assertEq(matic.balanceOf(user), 0);
assertEq(matic.balanceOf(0x000000000000000000000000000000000000dEaD), amount);
assertEq(matic.balanceOf(address(migration)), amount);
assertEq(polygon.balanceOf(user), amount);
}

function test_Unmigrate(address user, uint256 amount, uint256 amount2) external {
vm.assume(amount <= 10000000000 * 10 ** 18 && amount2 <= amount && user != address(0));
matic.mint(user, amount);
vm.startPrank(user);
matic.approve(address(migration), amount);
migration.migrate(amount);

assertEq(matic.balanceOf(user), 0);
assertEq(matic.balanceOf(address(migration)), amount);
assertEq(polygon.balanceOf(user), amount);

polygon.approve(address(migration), amount2);
migration.unmigrate(amount2);

assertEq(polygon.balanceOf(user), amount - amount2);
assertEq(matic.balanceOf(address(migration)), amount - amount2);
assertEq(matic.balanceOf(user), amount2);
}

function testRevert_UpdateReleaseTimestampOnlyGovernance(address user, uint256 timestamp) external {
vm.assume(timestamp >= block.timestamp && user != governance);
vm.expectRevert("Ownable: caller is not the owner");
Expand Down

0 comments on commit c48a185

Please sign in to comment.