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
985b853c
Unverified
Commit
985b853c
authored
Nov 17, 2022
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Add FuzzDecodeDepositTxDataToL1Info
op-node: More test cleanup
parent
8d127251
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
15 deletions
+41
-15
Makefile
op-node/Makefile
+1
-0
l1_block_info_tob_test.go
op-node/rollup/derive/l1_block_info_tob_test.go
+31
-2
state_tob_test.go
op-node/rollup/driver/state_tob_test.go
+9
-13
No files found.
op-node/Makefile
View file @
985b853c
...
@@ -35,6 +35,7 @@ fuzz:
...
@@ -35,6 +35,7 @@ fuzz:
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzParseL1InfoDepositTxDataValid ./rollup/derive
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzParseL1InfoDepositTxDataValid ./rollup/derive
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzParseL1InfoDepositTxDataBadLength ./rollup/derive
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzParseL1InfoDepositTxDataBadLength ./rollup/derive
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzRejectCreateBlockBadTimestamp ./rollup/driver
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzRejectCreateBlockBadTimestamp ./rollup/driver
go
test
-run
NOTAREALTEST
-v
-fuzztime
10s
-fuzz
FuzzDecodeDepositTxDataToL1Info ./rollup/driver
.PHONY
:
\
.PHONY
:
\
...
...
op-node/rollup/derive/l1_block_info_tob_test.go
View file @
985b853c
...
@@ -28,7 +28,7 @@ func FuzzParseL1InfoDepositTxDataValid(f *testing.F) {
...
@@ -28,7 +28,7 @@ func FuzzParseL1InfoDepositTxDataValid(f *testing.F) {
// Create our deposit tx from our info
// Create our deposit tx from our info
depTx
,
err
:=
L1InfoDeposit
(
seqNr
,
&
l1Info
,
sysCfg
)
depTx
,
err
:=
L1InfoDeposit
(
seqNr
,
&
l1Info
,
sysCfg
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
,
"error creating deposit tx from L1 info"
)
// Get our info from out deposit tx
// Get our info from out deposit tx
res
,
err
:=
L1InfoDepositTxData
(
depTx
.
Data
)
res
,
err
:=
L1InfoDepositTxData
(
depTx
.
Data
)
...
@@ -42,12 +42,41 @@ func FuzzParseL1InfoDepositTxDataValid(f *testing.F) {
...
@@ -42,12 +42,41 @@ func FuzzParseL1InfoDepositTxDataValid(f *testing.F) {
require
.
Equal
(
t
,
res
.
BlockHash
,
l1Info
.
Hash
())
require
.
Equal
(
t
,
res
.
BlockHash
,
l1Info
.
Hash
())
require
.
Equal
(
t
,
res
.
SequenceNumber
,
seqNr
)
require
.
Equal
(
t
,
res
.
SequenceNumber
,
seqNr
)
require
.
Equal
(
t
,
res
.
BatcherAddr
,
sysCfg
.
BatcherAddr
)
require
.
Equal
(
t
,
res
.
BatcherAddr
,
sysCfg
.
BatcherAddr
)
require
.
Equal
(
t
,
res
.
L1FeeOverhead
,
sysCfg
.
Overhead
)
require
.
Equal
(
t
,
res
.
L1FeeOverhead
,
sysCfg
.
Overhead
)
require
.
Equal
(
t
,
res
.
L1FeeScalar
,
sysCfg
.
Scalar
)
require
.
Equal
(
t
,
res
.
L1FeeScalar
,
sysCfg
.
Scalar
)
})
})
}
}
// Reverse of the above test. Accepts a random byte string and attempts to extract L1Info from it,
// then attempts to convert that info back into the tx data and compare it with the original input.
func
FuzzDecodeDepositTxDataToL1Info
(
f
*
testing
.
F
)
{
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
fuzzedData
[]
byte
)
{
// Get our info from out deposit tx
res
,
err
:=
L1InfoDepositTxData
(
fuzzedData
)
if
err
!=
nil
{
return
}
l1Info
:=
testutils
.
MockBlockInfo
{
InfoHash
:
res
.
BlockHash
,
InfoNum
:
res
.
Number
,
InfoTime
:
res
.
Time
,
InfoBaseFee
:
res
.
BaseFee
,
}
sysCfg
:=
eth
.
SystemConfig
{
BatcherAddr
:
res
.
BatcherAddr
,
Overhead
:
res
.
L1FeeOverhead
,
Scalar
:
res
.
L1FeeScalar
,
GasLimit
:
uint64
(
0
),
}
depTx
,
err
:=
L1InfoDeposit
(
res
.
SequenceNumber
,
&
l1Info
,
sysCfg
)
require
.
NoError
(
t
,
err
,
"error creating deposit tx from L1 info"
)
require
.
Equal
(
t
,
depTx
.
Data
,
fuzzedData
)
})
}
// FuzzParseL1InfoDepositTxDataBadLength is a fuzz test built from TestParseL1InfoDepositTxData, which constructs
// FuzzParseL1InfoDepositTxDataBadLength is a fuzz test built from TestParseL1InfoDepositTxData, which constructs
// random L1 deposit tx info and derives a tx from it, then derives the info back from the tx, to ensure round-trip
// random L1 deposit tx info and derives a tx from it, then derives the info back from the tx, to ensure round-trip
// derivation is upheld. This generates "invalid" data and ensures it always throws an error where expected.
// derivation is upheld. This generates "invalid" data and ensures it always throws an error where expected.
...
...
op-node/rollup/driver/state_tob_test.go
View file @
985b853c
...
@@ -14,7 +14,6 @@ import (
...
@@ -14,7 +14,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -136,24 +135,21 @@ func TestRejectCreateBlockBadTimestamp(t *testing.T) {
...
@@ -136,24 +135,21 @@ func TestRejectCreateBlockBadTimestamp(t *testing.T) {
if
l2HeadRef
.
Time
+
cfg
.
BlockTime
<
l2l1OriginBlock
.
Time
{
if
l2HeadRef
.
Time
+
cfg
.
BlockTime
<
l2l1OriginBlock
.
Time
{
// If not, we expect a specific error.
// If not, we expect a specific error.
// TODO: This isn't the cleanest, we should construct + compare the whole error message.
// TODO: This isn't the cleanest, we should construct + compare the whole error message.
assert
.
NotNil
(
t
,
err
)
require
.
NotNil
(
t
,
err
)
assert
.
Contains
(
t
,
err
.
Error
(),
"cannot build L2 block on top"
)
require
.
Contains
(
t
,
err
.
Error
(),
"cannot build L2 block on top"
)
assert
.
Contains
(
t
,
err
.
Error
(),
"for time"
)
require
.
Contains
(
t
,
err
.
Error
(),
"for time"
)
assert
.
Contains
(
t
,
err
.
Error
(),
"before L1 origin"
)
require
.
Contains
(
t
,
err
.
Error
(),
"before L1 origin"
)
return
return
}
}
// Otherwise we should have no error.
assert
.
Nil
(
t
,
err
)
// If we expected the outputter to error, capture that here
// If we expected the outputter to error, capture that here
if
outputProvider
.
willError
{
if
outputProvider
.
willError
{
assert
.
NotNil
(
t
,
err
,
"outputInterface failed to createNewBlock, so createNewL2Block should also have failed"
)
require
.
NotNil
(
t
,
err
,
"outputInterface failed to createNewBlock, so createNewL2Block should also have failed"
)
return
return
}
}
// Otherwise we should have no error.
// Otherwise we should have no error.
assert
.
Nil
(
t
,
err
)
require
.
NoError
(
t
,
err
,
"error raised in TestRejectCreateBlockBadTimestamp"
)
}
}
// FuzzRejectCreateBlockBadTimestamp is a property test derived from the TestRejectCreateBlockBadTimestamp unit test.
// FuzzRejectCreateBlockBadTimestamp is a property test derived from the TestRejectCreateBlockBadTimestamp unit test.
...
@@ -215,7 +211,7 @@ func FuzzRejectCreateBlockBadTimestamp(f *testing.F) {
...
@@ -215,7 +211,7 @@ func FuzzRejectCreateBlockBadTimestamp(f *testing.F) {
// Verify the L1Origin's timestamp is greater than L1 genesis in our config.
// Verify the L1Origin's timestamp is greater than L1 genesis in our config.
if
l2l1OriginBlock
.
Number
<
s
.
config
.
Genesis
.
L1
.
Number
{
if
l2l1OriginBlock
.
Number
<
s
.
config
.
Genesis
.
L1
.
Number
{
assert
.
Nil
(
t
,
err
)
require
.
NoError
(
t
,
err
)
return
return
}
}
...
@@ -231,11 +227,11 @@ func FuzzRejectCreateBlockBadTimestamp(f *testing.F) {
...
@@ -231,11 +227,11 @@ func FuzzRejectCreateBlockBadTimestamp(f *testing.F) {
}
}
// Otherwise we should have no error.
// Otherwise we should have no error.
assert
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
// If we expected the outputter to error, capture that here
// If we expected the outputter to error, capture that here
if
outputProvider
.
willError
{
if
outputProvider
.
willError
{
assert
.
NotNil
(
t
,
err
,
"outputInterface failed to createNewBlock, so createNewL2Block should also have failed"
)
require
.
NotNil
(
t
,
err
,
"outputInterface failed to createNewBlock, so createNewL2Block should also have failed"
)
return
return
}
}
...
...
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