Skip to content

Commit

Permalink
reinforce with test
Browse files Browse the repository at this point in the history
  • Loading branch information
vm06007 committed Jan 17, 2024
1 parent 3c96553 commit 17bbf2e
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions contracts/TimeLockFarmV2Dual.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,86 @@ contract TimeLockFarmV2DualTest is Test {
"Farm balance for user should be 20% less after exit"
);
}

function testScraping()
public
{
address withdrawAddress = ADMIN_ADDRESS;

uint256 availableToWithdrawInitially = farm.unlockable(
withdrawAddress
);

_simpleForwardTime();

uint256 availableToWithdrawNow = farm.unlockable(
withdrawAddress
);

console.log(availableToWithdrawNow, 'availableToWithdrawNow');

vm.startPrank(
withdrawAddress
);

uint256 tokensInWalletBeforeExit = farm.balanceOf(
withdrawAddress
);

farm.exitFarm();

uint256 tokensInWalletAfterExit = farm.balanceOf(
withdrawAddress
);

assertEq(
tokensInWalletBeforeExit,
tokensInWalletAfterExit + availableToWithdrawNow,
"Expected amount to withdraw must end up in user wallet"
);

uint256 availableToWithdrawAfterExit = farm.unlockable(
withdrawAddress
);

assertEq(
availableToWithdrawAfterExit,
0,
"After user exited counter of unlockable must be 0"
);

_simpleForwardTime();

availableToWithdrawAfterExit = farm.unlockable(
withdrawAddress
);

console.log(
availableToWithdrawAfterExit,
'availableToWithdrawAfterExit'
);

console.log(
availableToWithdrawNow - availableToWithdrawAfterExit,
'availableToWithdrawAfterExit'
);

assertGt(
availableToWithdrawAfterExit,
0,
"Once time passed amount should increase"
);

assertEq(
availableToWithdrawNow - availableToWithdrawAfterExit,
tokens(37500000),
"Compare with initial amount hardcoded"
);

assertEq(
availableToWithdrawNow - availableToWithdrawAfterExit,
availableToWithdrawInitially,
"Compare with initial amount"
);
}
}

0 comments on commit 17bbf2e

Please sign in to comment.