Skip to content

Commit

Permalink
Implement more machine codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed Jan 15, 2024
1 parent b57fab8 commit 8d18380
Show file tree
Hide file tree
Showing 3 changed files with 355 additions and 11 deletions.
38 changes: 35 additions & 3 deletions foundry_test/modules/utils/L2CompressorHuff.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface L2CompressorImps {
uint256 rindex,
uint256 size
) external pure returns (uint256, uint256);

function testReadBytes32(bytes32 _a, bytes32 _b, uint256 rindex, uint256 windex, uint256 flag) external pure returns (uint256, uint256, bytes32);
}

contract L2CompressorHuffTests is Test {
Expand All @@ -28,7 +30,9 @@ contract L2CompressorHuffTests is Test {
}

function test_load_dynamic_size() external {
(uint256 size, uint256 rindex) = imp.testLoadDynamicSize(
uint256 size; uint256 rindex;

(size, rindex) = imp.testLoadDynamicSize(
bytes32(0x082366f82de6ef3a1d439d0adbfa2ee606f86c2774b4d946f895dfc1f88443a2),
bytes32(0),
4,
Expand All @@ -41,8 +45,36 @@ contract L2CompressorHuffTests is Test {
(size, rindex) = imp.testLoadDynamicSize(
bytes32(0x082366f82de6ef3a1d439d0adbfa2ee606f86c2774b4d946f895dfc1f88443a2),
bytes32(0),
4 + 32 - 3,
2219024896
4 + 0,
2
);

assertEq(size, 2083);
assertEq(rindex, 4 + 2);

(size, rindex) = imp.testLoadDynamicSize(
bytes32(0x082366f82de6ef3a1d439d0adbfa2ee606f86c2774b4d946f895dfc1f88443a2),
bytes32(0),
4 + 2,
4
);

assertEq(size, 1727540710);
assertEq(rindex, 4 + 4 + 2);
}

function test_load_bytes32() external {
uint256 windex; uint256 rindex; bytes32 value;

(windex, rindex, value) = imp.testReadBytes32(
bytes32(0x020166f82de6ef3a1d439d0adbfa2ee606f86c2774b4d946f895dfc1f88443a2),
bytes32(0),
4,
0,
0x23
);

assertEq(windex, 32);
assertEq(rindex, 4 + 2);
}
}
Loading

0 comments on commit 8d18380

Please sign in to comment.