Compare commits

..

No commits in common. "446edaca3e7fe74398b97c7f97964fc04600214d" and "8a51ae5cf585cf614c039f0974db0877af2e8ac6" have entirely different histories.

3 changed files with 1 additions and 54 deletions

View File

@ -4,15 +4,11 @@ pragma solidity ^0.8.20;
contract Wallet { contract Wallet {
address payable public owner; address payable public owner;
event Deposit(address account, uint256 amount);
constructor () payable { constructor () payable {
owner = payable(msg.sender); owner = payable(msg.sender);
} }
receive() external payable { receive() external payable {}
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint256 _amount) external { function withdraw(uint256 _amount) external {
require(msg.sender == owner, "caller is not owner"); require(msg.sender == owner, "caller is not owner");

View File

@ -1,4 +1,3 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20; pragma solidity ^0.8.20;
import "forge-std/Test.sol"; import "forge-std/Test.sol";

View File

@ -1,48 +0,0 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import "forge-std/Test.sol";
import {Wallet} from "../src/Wallet.sol";
// Examples of deal and hoax
// deal(address, uint) - Set balance of address
// hoax(address, uint) - deal + prank, Sets up a prank and set balance
contract WalletTest is Test {
Wallet public wallet;
function setUp() public {
wallet = new Wallet{value: 1e18}();
}
function _send(uint256 amount) private {
(bool ok,) = address(wallet).call{value: amount}("");
require(ok, "send ETH failed");
}
function testEthBalance() public {
console.log("ETH balance", address(this).balance / 1e18);
}
function testSendEth() public {
uint bal = address(wallet).balance;
// deal(address, uint) - Set balance of address
deal(address(1), 100);
assertEq(address(1).balance, 100);
deal(address(1), 10);
assertEq(address(1).balance, 10);
// hoax(address, uint) - deal + prank, Sets up a prank and set balance
deal(address(1), 123e18);
vm.prank(address(1));
_send(123e18);
hoax(address(1), 456e18);
_send(456e18);
assertEq(address(wallet).balance, bal + 123e18 + 456e18);
}
}