File tree Expand file tree Collapse file tree 2 files changed +132
-0
lines changed
Expand file tree Collapse file tree 2 files changed +132
-0
lines changed Original file line number Diff line number Diff line change 1+ #define macro MAIN() = takes (0) returns (1) {
2+ // This is a test for long jumps
3+ // We'll create a lot of opcodes before the label to push the offset beyond 255 bytes
4+
5+ 0x01 0x01 add
6+ 0x01 add
7+ 0x01 add
8+ 0x01 add
9+ 0x01 add
10+ 0x01 add
11+ 0x01 add
12+ 0x01 add
13+ 0x01 add
14+ 0x01 add
15+ 0x01 add
16+ 0x01 add
17+ 0x01 add
18+ 0x01 add
19+ 0x01 add
20+ 0x01 add
21+ 0x01 add
22+ 0x01 add
23+ 0x01 add
24+ 0x01 add
25+ 0x01 add
26+ 0x01 add
27+ 0x01 add
28+ 0x01 add
29+ 0x01 add
30+ 0x01 add
31+ 0x01 add
32+ 0x01 add
33+ 0x01 add
34+ 0x01 add
35+ 0x01 add
36+ 0x01 add
37+ 0x01 add
38+ 0x01 add
39+ 0x01 add
40+ 0x01 add
41+ 0x01 add
42+ 0x01 add
43+ 0x01 add
44+ 0x01 add
45+ 0x01 add
46+ 0x01 add
47+ 0x01 add
48+ 0x01 add
49+ 0x01 add
50+ 0x01 add
51+ 0x01 add
52+ 0x01 add
53+ 0x01 add
54+ 0x01 add
55+ 0x01 add
56+ 0x01 add
57+ 0x01 add
58+ 0x01 add
59+ 0x01 add
60+ 0x01 add
61+ 0x01 add
62+ 0x01 add
63+ 0x01 add
64+ 0x01 add
65+ 0x01 add
66+ 0x01 add
67+ 0x01 add
68+ 0x01 add
69+ 0x01 add
70+ 0x01 add
71+ 0x01 add
72+ 0x01 add
73+ 0x01 add
74+ 0x01 add
75+ 0x01 add
76+ 0x01 add
77+ 0x01 add
78+ 0x01 add
79+ 0x01 add
80+ 0x01 add
81+ 0x01 add
82+ 0x01 add
83+ 0x01 add
84+ 0x01 add
85+ 0x01 add
86+ 0x01 add
87+ 0x01 add
88+ 0x01 add
89+
90+ // Store "Hello, World!" in memory
91+ 0x48656c6c6f2c20576f726c6421
92+ 0x00 mstore
93+
94+ // Jump to success label (should be beyond byte 255)
95+ success
96+ jump
97+
98+ // Revert if this point is reached
99+ 0x00 0x00 revert
100+
101+ success:
102+ 0x20 0x00 return
103+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: UNLICENSED
2+ pragma solidity ^ 0.8.13 ;
3+
4+ import {Test, console} from "forge-std/Test.sol " ;
5+ import {PuffDeployer} from "../src/Deployers.sol " ;
6+
7+ // These interfaces define callable functions on our test contracts
8+ interface ISaysHello {
9+ function sayHello () external view returns (bytes32 );
10+ }
11+
12+ contract LongJumpsTest is Test {
13+ PuffDeployer public puffDeployer;
14+
15+ function setUp () public {
16+ puffDeployer = new PuffDeployer ();
17+ }
18+
19+ function test_longJump () public {
20+ address newContract = puffDeployer.deployContract ("examples/long_jump.huff " );
21+ ISaysHello jumper = ISaysHello (newContract);
22+ bytes32 message = jumper.sayHello ();
23+
24+ // The expected output is "Hello, World!" right-aligned in a bytes32
25+
26+ assertEq (message, 0x0000000000000000000000000000000000000048656c6c6f2c20576f726c6421 );
27+ }
28+
29+ }
You can’t perform that action at this time.
0 commit comments