Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
ff589085
Commit
ff589085
authored
Dec 13, 2022
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slice across multiple words test
gas snapshot cp nit
parent
89f70c59
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+1
-0
Bytes.t.sol
packages/contracts-bedrock/contracts/test/Bytes.t.sol
+13
-1
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
ff589085
...
@@ -9,6 +9,7 @@ GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 88513)
...
@@ -9,6 +9,7 @@ GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 88513)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 74998)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 74998)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 36156)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 36156)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 167240)
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_acrossWords_works() (gas: 1397)
Bytes_Test:test_slice_fromNonZeroIdx_works() (gas: 17218)
Bytes_Test:test_slice_fromNonZeroIdx_works() (gas: 17218)
Bytes_Test:test_slice_fromZeroIdx_works() (gas: 20826)
Bytes_Test:test_slice_fromZeroIdx_works() (gas: 20826)
...
...
packages/contracts-bedrock/contracts/test/Bytes.t.sol
View file @
ff589085
...
@@ -53,6 +53,18 @@ contract Bytes_Test is Test {
...
@@ -53,6 +53,18 @@ contract Bytes_Test is Test {
assertEq(Bytes.slice(input, 31, 2), hex"1122");
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`,
/// @dev Tests that, when given an input bytes array of length `n`,
/// the `slice` function will always revert if `_start + _length > n`.
/// the `slice` function will always revert if `_start + _length > n`.
function testFuzz_slice_outOfBounds_reverts(
function testFuzz_slice_outOfBounds_reverts(
...
@@ -138,7 +150,7 @@ contract Bytes_Test is Test {
...
@@ -138,7 +150,7 @@ contract Bytes_Test is Test {
assertEq(input.length, 0);
assertEq(input.length, 0);
assertEq(expected.length, 0);
assertEq(expected.length, 0);
assertEq(actual.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
/// @dev Test that the `equal` function in the `Bytes` library returns `false` if given
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment