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
6294e02e
Commit
6294e02e
authored
Mar 14, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nextTxData tests :test_tube:
parent
7bdcb0ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
7 deletions
+46
-7
channel_manager_test.go
op-batcher/batcher/channel_manager_test.go
+46
-7
No files found.
op-batcher/batcher/channel_manager_test.go
View file @
6294e02e
package
batcher
_test
package
batcher
import
(
"io"
...
...
@@ -7,7 +7,6 @@ import (
"testing"
"time"
"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"
derivetest
"github.com/ethereum-optimism/optimism/op-node/rollup/derive/test"
...
...
@@ -23,7 +22,7 @@ import (
// 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
{})
m
:=
NewChannelManager
(
log
,
ChannelConfig
{})
a
:=
types
.
NewBlock
(
&
types
.
Header
{
Number
:
big
.
NewInt
(
0
),
...
...
@@ -48,14 +47,14 @@ func TestChannelManagerReturnsErrReorg(t *testing.T) {
err
=
m
.
AddL2Block
(
c
)
require
.
NoError
(
t
,
err
)
err
=
m
.
AddL2Block
(
x
)
require
.
ErrorIs
(
t
,
err
,
batcher
.
ErrReorg
)
require
.
ErrorIs
(
t
,
err
,
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
{
m
:=
NewChannelManager
(
log
,
ChannelConfig
{
TargetFrameSize
:
0
,
MaxFrameSize
:
120
_000
,
ApproxComprRatio
:
1.0
,
...
...
@@ -86,14 +85,54 @@ func TestChannelManagerReturnsErrReorgWhenDrained(t *testing.T) {
require
.
ErrorIs
(
t
,
err
,
io
.
EOF
)
err
=
m
.
AddL2Block
(
x
)
require
.
ErrorIs
(
t
,
err
,
batcher
.
ErrReorg
)
require
.
ErrorIs
(
t
,
err
,
ErrReorg
)
}
// TestChannelManagerNextTxData checks the nextTxData function.
func
TestChannelManagerNextTxData
(
t
*
testing
.
T
)
{
log
:=
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
m
:=
NewChannelManager
(
log
,
ChannelConfig
{})
// Nil pending channel should return EOF
returnedTxData
,
err
:=
m
.
nextTxData
()
require
.
ErrorIs
(
t
,
err
,
io
.
EOF
)
require
.
Equal
(
t
,
txData
{},
returnedTxData
)
// Set the pending channel
// The nextTxData function should still return EOF
// since the pending channel has no frames
m
.
ensurePendingChannel
(
eth
.
BlockID
{})
returnedTxData
,
err
=
m
.
nextTxData
()
require
.
ErrorIs
(
t
,
err
,
io
.
EOF
)
require
.
Equal
(
t
,
txData
{},
returnedTxData
)
// Manually push a frame into the pending channel
channelID
:=
m
.
pendingChannel
.
ID
()
frame
:=
frameData
{
data
:
[]
byte
{},
id
:
frameID
{
chID
:
channelID
,
frameNumber
:
uint16
(
0
),
},
}
m
.
pendingChannel
.
PushFrame
(
frame
)
require
.
Equal
(
t
,
1
,
m
.
pendingChannel
.
NumFrames
())
// Now the nextTxData function should return the frame
returnedTxData
,
err
=
m
.
nextTxData
()
expectedTxData
:=
txData
{
frame
}
expectedChannelID
:=
expectedTxData
.
ID
()
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
expectedTxData
,
returnedTxData
)
require
.
Equal
(
t
,
0
,
m
.
pendingChannel
.
NumFrames
())
require
.
Equal
(
t
,
expectedTxData
,
m
.
pendingTransactions
[
expectedChannelID
])
}
func
TestChannelManager_TxResend
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
rng
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
log
:=
testlog
.
Logger
(
t
,
log
.
LvlError
)
m
:=
batcher
.
NewChannelManager
(
log
,
batcher
.
ChannelConfig
{
m
:=
NewChannelManager
(
log
,
ChannelConfig
{
TargetFrameSize
:
0
,
MaxFrameSize
:
120
_000
,
ApproxComprRatio
:
1.0
,
...
...
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