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
8d127251
Unverified
Commit
8d127251
authored
Nov 17, 2022
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: clean up FuzzParseL1InfoDepositTxDataValid
parent
c3af0455
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
30 deletions
+12
-30
l1_block_info_tob_test.go
op-node/rollup/derive/l1_block_info_tob_test.go
+12
-30
No files found.
op-node/rollup/derive/l1_block_info_tob_test.go
View file @
8d127251
package
derive
package
derive
import
(
import
(
"math/big"
"math/rand"
"testing"
"testing"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum-optimism/optimism/op-node/testutils/fuzzerutils"
"github.com/ethereum-optimism/optimism/op-node/testutils/fuzzerutils"
"github.com/ethereum/go-ethereum/common"
fuzz
"github.com/google/gofuzz"
fuzz
"github.com/google/gofuzz"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -17,37 +14,20 @@ import (
...
@@ -17,37 +14,20 @@ import (
// L1 deposit tx info and derives a tx from it, then derives the info back from the tx, to ensure round-trip
// 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 "valid" data and ensures it is always derived back to original values.
// derivation is upheld. This generates "valid" data and ensures it is always derived back to original values.
func
FuzzParseL1InfoDepositTxDataValid
(
f
*
testing
.
F
)
{
func
FuzzParseL1InfoDepositTxDataValid
(
f
*
testing
.
F
)
{
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
fuzzedData
[]
byte
,
seqNr
uint64
,
rngSeed
int64
)
{
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
fuzzedData
[]
byte
)
{
// Create our fuzzer wrapper to generate complex values
// Create our fuzzer wrapper to generate complex values
typeProvider
:=
fuzz
.
NewFromGoFuzz
(
fuzzedData
)
.
NilChance
(
0
)
.
MaxDepth
(
10000
)
.
NumElements
(
0
,
0x100
)
typeProvider
:=
fuzz
.
NewFromGoFuzz
(
fuzzedData
)
.
NilChance
(
0
)
.
MaxDepth
(
10000
)
.
NumElements
(
0
,
0x100
)
fuzzerutils
.
AddFuzzerFunctions
(
typeProvider
)
fuzzerutils
.
AddFuzzerFunctions
(
typeProvider
)
// Generate our fuzzed value types to construct our L1 info
var
l1Info
testutils
.
MockBlockInfo
var
fuzzVars
struct
{
typeProvider
.
Fuzz
(
&
l1Info
)
InfoBaseFee
*
big
.
Int
var
seqNr
uint64
InfoTime
uint64
typeProvider
.
Fuzz
(
&
seqNr
)
InfoNum
uint64
var
sysCfg
eth
.
SystemConfig
// InfoSequenceNumber uint64
typeProvider
.
Fuzz
(
&
sysCfg
)
}
typeProvider
.
Fuzz
(
&
fuzzVars
)
// Create an rng provider and construct an L1 info from random + fuzzed data.
rng
:=
rand
.
New
(
rand
.
NewSource
(
rngSeed
))
// just go instantiate the struct instead of calling MakeL1Info
// see what has become of it.
l1Info
:=
testutils
.
MakeBlockInfo
(
func
(
l
*
testutils
.
MockBlockInfo
)
{
l
.
InfoBaseFee
=
fuzzVars
.
InfoBaseFee
l
.
InfoTime
=
fuzzVars
.
InfoTime
l
.
InfoNum
=
fuzzVars
.
InfoNum
})(
rng
)
// Create our deposit tx from our info
// Create our deposit tx from our info
testSysCfg
:=
eth
.
SystemConfig
{
depTx
,
err
:=
L1InfoDeposit
(
seqNr
,
&
l1Info
,
sysCfg
)
BatcherAddr
:
common
.
Address
{
42
},
Overhead
:
[
32
]
byte
{},
Scalar
:
[
32
]
byte
{},
}
depTx
,
err
:=
L1InfoDeposit
(
seqNr
,
l1Info
,
testSysCfg
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// Get our info from out deposit tx
// Get our info from out deposit tx
...
@@ -61,8 +41,10 @@ func FuzzParseL1InfoDepositTxDataValid(f *testing.F) {
...
@@ -61,8 +41,10 @@ func FuzzParseL1InfoDepositTxDataValid(f *testing.F) {
require
.
Equal
(
t
,
res
.
BaseFee
.
Bytes
(),
l1Info
.
BaseFee
()
.
Bytes
())
require
.
Equal
(
t
,
res
.
BaseFee
.
Bytes
(),
l1Info
.
BaseFee
()
.
Bytes
())
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
)
l1CfgFetcher
:=
&
testutils
.
MockL2Client
{}
require
.
Equal
(
t
,
res
.
BatcherAddr
,
sysCfg
.
BatcherAddr
)
l1CfgFetcher
.
ExpectSystemConfigByL2Hash
(
res
.
BlockHash
,
testSysCfg
,
nil
)
require
.
Equal
(
t
,
res
.
L1FeeOverhead
,
sysCfg
.
Overhead
)
require
.
Equal
(
t
,
res
.
L1FeeScalar
,
sysCfg
.
Scalar
)
})
})
}
}
...
...
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