forked from RareSkills/huff-puzzles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CallValue.t.sol
45 lines (38 loc) · 1.25 KB
/
CallValue.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
// 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 CallValue {}
contract CallValueTest is Test {
CallValue public callValue;
function setUp() public {
callValue = CallValue(HuffDeployer.config().deploy("CallValue"));
}
function testCallValue() public {
vm.deal(address(this), 2 ether);
(bool success, bytes memory retdata) = address(callValue).call{
value: 1 ether
}("");
require(success, "call failed");
assertEq(
abi.decode(retdata, (uint256)),
1 ether,
"Expected retdata to be 1 ether"
);
(success, retdata) = address(callValue).call("");
require(success, "call failed");
assertEq(
abi.decode(retdata, (uint256)),
0,
"Expected retdata to be 1 ether"
);
(success, retdata) = address(callValue).call{value: 0.5 ether}("");
require(success, "call failed");
assertEq(
abi.decode(retdata, (uint256)),
0.5 ether,
"Expected retdata to be 1 ether"
);
}
}