File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1313 [sz-str (if (odd? (string-length sz-str))
1414 (string-append "0" sz-str)
1515 sz-str)]
16- [sz-hex-str (string-append "0x" sz-str)])
17- (append (hex->instrs sz-hex-str) '("DUP1" "PUSH1" "0x09" "RETURNDATASIZE" "CODECOPY" "RETURNDATASIZE" "RETURN"))))
16+ [sz-hex-str (string-append "0x" sz-str)]
17+ ;; Calculate the correct offset based on length bytes
18+ [length-bytes (ceiling (/ (string-length sz-str) 2))]
19+ [offset-str (number->string (+ 9 (- length-bytes 1)) 16)]
20+ [offset-str (if (odd? (string-length offset-str))
21+ (string-append "0" offset-str)
22+ offset-str)]
23+ [offset-val (format "0x~a" offset-str)])
24+ (append (hex->instrs sz-hex-str) (list "DUP1" "PUSH1" offset-val "RETURNDATASIZE" "CODECOPY" "RETURNDATASIZE" "RETURN"))))
1825
1926(provide
2027 generate-copy-constructor)
Original file line number Diff line number Diff line change 22pragma solidity ^0.8.13;
33
44import {Test, console} from "forge-std/Test.sol";
5- import {PuffDeployer} from "../src/Deployers.sol";
5+ import {PuffDeployer, HuffDeployer } from "../src/Deployers.sol";
66
77// These interfaces define callable functions on our test contracts
88interface ISaysHello {
@@ -11,9 +11,11 @@ interface ISaysHello {
1111
1212contract LongJumpsTest is Test {
1313 PuffDeployer public puffDeployer;
14+ HuffDeployer public huffDeployer;
1415
1516 function setUp() public {
1617 puffDeployer = new PuffDeployer();
18+ huffDeployer = new HuffDeployer();
1719 }
1820
1921 function test_longJump() public {
@@ -26,4 +28,14 @@ contract LongJumpsTest is Test {
2628 assertEq(message, 0x0000000000000000000000000000000000000048656c6c6f2c20576f726c6421);
2729 }
2830
31+ function test_longJump_Huff() public {
32+ address newContract = huffDeployer.deployContract("examples/long_jump.huff");
33+ ISaysHello jumper = ISaysHello(newContract);
34+ bytes32 message = jumper.sayHello();
35+
36+ // The expected output is "Hello, World!" right-aligned in a bytes32
37+
38+ assertEq(message, 0x0000000000000000000000000000000000000048656c6c6f2c20576f726c6421);
39+ }
40+
2941}
You can’t perform that action at this time.
0 commit comments