forked from RareSkills/huff-puzzles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Multiply.t.sol
51 lines (43 loc) · 1.38 KB
/
Multiply.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
48
49
50
51
// 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";
import {NonMatchingSelectorHelper} from "./test-utils/NonMatchingSelectorHelper.sol";
interface Multiply {
function multiply(
uint256 num1,
uint256 num2
) external pure returns (uint256);
}
contract MultiplyTest is Test, NonMatchingSelectorHelper {
Multiply public multiply;
function setUp() public {
multiply = Multiply(HuffDeployer.config().deploy("Multiply"));
}
function testMultiply() public {
assertEq(
multiply.multiply(2, 3),
6,
"Multiply(2, 3) expected to return 6"
);
assertEq(
multiply.multiply(0, 1),
0,
"Multiply(0, 1) expected to return 0"
);
vm.expectRevert();
multiply.multiply(2, type(uint256).max);
}
/// @notice Test that a non-matching selector reverts
function testNonMatchingSelector(bytes32 callData) public {
bytes4[] memory func_selectors = new bytes4[](1);
func_selectors[0] = Multiply.multiply.selector;
bool success = nonMatchingSelectorHelper(
func_selectors,
callData,
address(multiply)
);
assert(!success);
}
}