Commit ff589085 authored by clabby's avatar clabby

Slice across multiple words test

gas snapshot

cp nit
parent 89f70c59
......@@ -9,6 +9,7 @@ GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 88513)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 74998)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 36156)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 167240)
Bytes_Test:test_slice_acrossMultipleWords_works() (gas: 9391)
Bytes_Test:test_slice_acrossWords_works() (gas: 1397)
Bytes_Test:test_slice_fromNonZeroIdx_works() (gas: 17218)
Bytes_Test:test_slice_fromZeroIdx_works() (gas: 20826)
......
......@@ -53,6 +53,18 @@ contract Bytes_Test is Test {
assertEq(Bytes.slice(input, 31, 2), hex"1122");
}
/// @dev Tests that the `slice` function works as expected when slicing between
/// multiple words in memory. In this case, we test that a 34 byte slice between
/// 3 separate words returns the correct result.
function test_slice_acrossMultipleWords_works() public {
bytes
memory input = hex"000000000000000000000000000000000000000000000000000000000000001122FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1100000000000000000000000000000000000000000000000000000000000000";
bytes
memory expected = hex"1122FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11";
assertEq(Bytes.slice(input, 31, 34), expected);
}
/// @dev Tests that, when given an input bytes array of length `n`,
/// the `slice` function will always revert if `_start + _length > n`.
function testFuzz_slice_outOfBounds_reverts(
......@@ -138,7 +150,7 @@ contract Bytes_Test is Test {
assertEq(input.length, 0);
assertEq(expected.length, 0);
assertEq(actual.length, 0);
assertEq(Bytes.toNibbles(input), expected);
assertEq(actual, expected);
}
/// @dev Test that the `equal` function in the `Bytes` library returns `false` if given
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment