-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00-Depositor.t.sol
44 lines (31 loc) · 1.19 KB
/
00-Depositor.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console} from "forge-std/Test.sol";
import {Vault, SmartWalletReceiver} from "../src/01-CallerV1.sol";
contract CallerV1Test is Test {
address user;
Vault public vault;
function setUp() public {
vault = new Vault();
user = address(new SmartWalletReceiver());
vm.deal(user, 10 ether);
vm.prank(user);
vault.deposit{value: 10 ether}();
}
function test_Depositor() public {
address attacker = makeAddr("ATTACKER");
vm.deal(attacker, 1 ether);
vm.startPrank(user);
// START OF SOLUTION
// (You can create any additional contract if needed)
vault.withdraw();
// END OF SOLUTION
vm.stopPrank();
uint256 userBalanceETH = address(user).balance;
assertEq(userBalanceETH, 10 ether, "User should get their ETH back");
uint256 userBalanceInVault = vault.balances(user);
assertEq(userBalanceInVault, 0, "User shouldn't have balance in the vault");
uint256 vaultBalanceETH = address(vault).balance;
assertEq(vaultBalanceETH, 0, "Vault shouldn't have any ETH");
}
}