forked from RareSkills/huff-puzzles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyEtherBalance.t.sol
47 lines (40 loc) · 1.57 KB
/
MyEtherBalance.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
45
46
47
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import {HuffConfig} from "foundry-huff/HuffConfig.sol";
import {HuffDeployer} from "foundry-huff/HuffDeployer.sol";
interface MyEtherBalance {}
contract MyEtherBalanceTest is Test {
MyEtherBalance public myEtherBalance;
function setUp() public {
myEtherBalance = MyEtherBalance(
HuffDeployer.config().deploy("MyEtherBalance")
);
}
function testMyEtherBalance() public {
vm.startPrank(address(this), address(this));
(bool success, bytes memory data) = address(myEtherBalance).call("");
require(success, "call failed");
assertEq(
abi.decode(data, (uint256)),
79228162514264337593543950335, // uint256(0xffffffffffffffffffffffff) -> default ether balance of an address with 0 initial balance making a call/staticcall/delegatecall
"expected ether balance of caller to be 79228162514264337593543950335"
);
vm.deal(address(this), 1 ether);
(success, data) = address(myEtherBalance).call("");
require(success, "call failed");
assertEq(
abi.decode(data, (uint256)),
1 ether,
"expected ether balance of caller to be 1"
);
vm.deal(address(this), 2 ether);
(success, data) = address(myEtherBalance).call("");
require(success, "call failed");
assertEq(
abi.decode(data, (uint256)),
2 ether,
"expected ether balance of caller to be 2"
);
}
}