Skip to content

Commit

Permalink
test(escrow-contract): add test for cancelling thawing escrow account…
Browse files Browse the repository at this point in the history
… funds

Signed-off-by: Bryan Cole <[email protected]>
  • Loading branch information
ColePBryan committed Aug 17, 2023
1 parent 64802fc commit 16971b0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/Escrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,29 @@ contract EscrowContractTest is Test {
// Simulate passing the freeze period
vm.warp(block.timestamp + WITHDRAW_ESCROW_FREEZE_PERIOD + 1);

// Cancel thaw and attempt to withdraw (expect revert)
vm.startPrank(SENDER_ADDRESS);
escrowContract.cancelThaw(receiverAddress);

uint256 senderBalanceBeforeWithdraw = mockERC20.balanceOf(SENDER_ADDRESS);
vm.expectRevert(Escrow.EscrowNotThawing.selector);
escrowContract.withdraw(receiverAddress);
uint256 senderBalanceAfterWithdraw = mockERC20.balanceOf(SENDER_ADDRESS);

assertEq(senderBalanceAfterWithdraw - senderBalanceBeforeWithdraw, 0, "Incorrect removed amount");

// Sets msg.sender address for next contract calls until stop is called
vm.startPrank(SENDER_ADDRESS);
escrowContract.thaw(receiverAddress, ESCROW_AMOUNT);

// Simulate passing the freeze period
vm.warp(block.timestamp + WITHDRAW_ESCROW_FREEZE_PERIOD + 1);

senderBalanceBeforeWithdraw = mockERC20.balanceOf(SENDER_ADDRESS);
vm.expectRevert(Escrow.EscrowNotThawing.selector);
escrowContract.withdraw(receiverAddress);
senderBalanceAfterWithdraw = mockERC20.balanceOf(SENDER_ADDRESS);

uint256 removedAmount = senderBalanceAfterWithdraw - senderBalanceBeforeWithdraw;

assertEq(removedAmount, ESCROW_AMOUNT, "Incorrect removed amount");
Expand Down

0 comments on commit 16971b0

Please sign in to comment.