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
34ce8dad
Unverified
Commit
34ce8dad
authored
Mar 02, 2023
by
mergify[bot]
Committed by
GitHub
Mar 02, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4907 from ethereum-optimism/jg/batcher_l2_reorg_tests
op-batcher: Unit test L2 Reorg Handling
parents
29787f64
ce62df90
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
channel_manager_test.go
op-batcher/batcher/channel_manager_test.go
+86
-0
No files found.
op-batcher/batcher/channel_manager_test.go
0 → 100644
View file @
34ce8dad
package
batcher_test
import
(
"io"
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/stretchr/testify/require"
)
// TestChannelManagerReturnsErrReorg ensures that the channel manager
// detects a reorg when it has cached L1 blocks.
func
TestChannelManagerReturnsErrReorg
(
t
*
testing
.
T
)
{
log
:=
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
m
:=
batcher
.
NewChannelManager
(
log
,
batcher
.
ChannelConfig
{})
a
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
0
),
},
nil
,
nil
,
nil
,
nil
)
b
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
1
),
ParentHash
:
a
.
Hash
(),
},
nil
,
nil
,
nil
,
nil
)
c
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
2
),
ParentHash
:
b
.
Hash
(),
},
nil
,
nil
,
nil
,
nil
)
x
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
2
),
ParentHash
:
common
.
Hash
{
0xff
},
},
nil
,
nil
,
nil
,
nil
)
err
:=
m
.
AddL2Block
(
a
)
require
.
NoError
(
t
,
err
)
err
=
m
.
AddL2Block
(
b
)
require
.
NoError
(
t
,
err
)
err
=
m
.
AddL2Block
(
c
)
require
.
NoError
(
t
,
err
)
err
=
m
.
AddL2Block
(
x
)
require
.
ErrorIs
(
t
,
err
,
batcher
.
ErrReorg
)
}
// TestChannelManagerReturnsErrReorgWhenDrained ensures that the channel manager
// detects a reorg even if it does not have any blocks inside it.
func
TestChannelManagerReturnsErrReorgWhenDrained
(
t
*
testing
.
T
)
{
log
:=
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
m
:=
batcher
.
NewChannelManager
(
log
,
batcher
.
ChannelConfig
{
TargetFrameSize
:
0
,
MaxFrameSize
:
100
,
ApproxComprRatio
:
1.0
,
})
lBlock
:=
types
.
NewBlock
(
&
types
.
Header
{
BaseFee
:
big
.
NewInt
(
10
),
Difficulty
:
common
.
Big0
,
Number
:
big
.
NewInt
(
100
),
},
nil
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
l1InfoTx
,
err
:=
derive
.
L1InfoDeposit
(
0
,
lBlock
,
eth
.
SystemConfig
{},
false
)
require
.
NoError
(
t
,
err
)
txs
:=
[]
*
types
.
Transaction
{
types
.
NewTx
(
l1InfoTx
)}
a
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
0
),
},
txs
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
x
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
1
),
ParentHash
:
common
.
Hash
{
0xff
},
},
txs
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
err
=
m
.
AddL2Block
(
a
)
require
.
NoError
(
t
,
err
)
_
,
_
,
err
=
m
.
TxData
(
eth
.
BlockID
{})
require
.
NoError
(
t
,
err
)
_
,
_
,
err
=
m
.
TxData
(
eth
.
BlockID
{})
require
.
ErrorIs
(
t
,
err
,
io
.
EOF
)
err
=
m
.
AddL2Block
(
x
)
require
.
ErrorIs
(
t
,
err
,
batcher
.
ErrReorg
)
}
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