Skip to content

Commit

Permalink
✅ Test depositEth check
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders committed Nov 29, 2023
1 parent 1b20f3b commit 3a8f1c0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/EthManagement.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ contract Deposit is EthManagementTest {
assertEq(address(engine).balance, AMOUNT);
}

function test_depositEth_Account_Doesnt_Exist() public {
uint128 invalidAccountId = type(uint128).max;
assert(perpsMarketProxy.getAccountOwner(invalidAccountId) == address(0));

vm.expectRevert(IEngine.AccountDoesNotExist.selector);
engine.depositEth{value: AMOUNT}(invalidAccountId);
}

function test_depositEth_via_trustedForwarder() public {
TrustedMulticallForwarder.Call3Value memory call =
TrustedMulticallForwarder.Call3Value(
Expand Down Expand Up @@ -112,10 +120,15 @@ contract Deposit is EthManagementTest {
) public {
vm.assume(fuzzedEthAmount < address(this).balance - 1 ether);

engine.depositEth{value: fuzzedEthAmount}(fuzzedAccountId);
if (perpsMarketProxy.getAccountOwner(fuzzedAccountId) == address(0)) {
vm.expectRevert(IEngine.AccountDoesNotExist.selector);
engine.depositEth{value: fuzzedEthAmount}(fuzzedAccountId);
} else {
engine.depositEth{value: fuzzedEthAmount}(fuzzedAccountId);

assertEq(engine.ethBalances(fuzzedAccountId), fuzzedEthAmount);
assertEq(address(engine).balance, fuzzedEthAmount);
assertEq(engine.ethBalances(fuzzedAccountId), fuzzedEthAmount);
assertEq(address(engine).balance, fuzzedEthAmount);
}
}

function test_depositEth_event() public {
Expand Down

0 comments on commit 3a8f1c0

Please sign in to comment.