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
4c4bdc3b
Commit
4c4bdc3b
authored
Mar 17, 2023
by
Sebastian Stammler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Test channelBuilder.InputBytes
parent
1a9e9475
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
channel_builder.go
op-batcher/batcher/channel_builder.go
+3
-0
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+35
-0
No files found.
op-batcher/batcher/channel_builder.go
View file @
4c4bdc3b
...
@@ -196,6 +196,9 @@ func (c *channelBuilder) Reset() error {
...
@@ -196,6 +196,9 @@ func (c *channelBuilder) Reset() error {
// AddBlock returns a ChannelFullError if called even though the channel is
// AddBlock returns a ChannelFullError if called even though the channel is
// already full. See description of FullErr for details.
// already full. See description of FullErr for details.
//
//
// AddBlock also returns the L1BlockInfo that got extracted from the block's
// first transaction for subsequent use by the caller.
//
// Call OutputFrames() afterwards to create frames.
// Call OutputFrames() afterwards to create frames.
func
(
c
*
channelBuilder
)
AddBlock
(
block
*
types
.
Block
)
(
derive
.
L1BlockInfo
,
error
)
{
func
(
c
*
channelBuilder
)
AddBlock
(
block
*
types
.
Block
)
(
derive
.
L1BlockInfo
,
error
)
{
if
c
.
IsFull
()
{
if
c
.
IsFull
()
{
...
...
op-batcher/batcher/channel_builder_test.go
View file @
4c4bdc3b
...
@@ -634,3 +634,38 @@ func TestFramePublished(t *testing.T) {
...
@@ -634,3 +634,38 @@ func TestFramePublished(t *testing.T) {
// Now the timeout will be 1000
// Now the timeout will be 1000
require
.
Equal
(
t
,
uint64
(
1000
),
cb
.
timeout
)
require
.
Equal
(
t
,
uint64
(
1000
),
cb
.
timeout
)
}
}
func
TestChannelBuilder_InputBytes
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
rng
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
cb
,
_
:=
defaultChannelBuilderSetup
(
t
)
require
.
Zero
(
cb
.
InputBytes
())
var
l
int
for
i
:=
0
;
i
<
5
;
i
++
{
block
:=
newMiniL2Block
(
rng
.
Intn
(
32
))
l
+=
blockBatchRlpSize
(
t
,
block
)
_
,
err
:=
cb
.
AddBlock
(
block
)
require
.
NoError
(
err
)
require
.
Equal
(
cb
.
InputBytes
(),
l
)
}
}
func
defaultChannelBuilderSetup
(
t
*
testing
.
T
)
(
*
channelBuilder
,
ChannelConfig
)
{
t
.
Helper
()
cfg
:=
defaultTestChannelConfig
cb
,
err
:=
newChannelBuilder
(
cfg
)
require
.
NoError
(
t
,
err
,
"newChannelBuilder"
)
return
cb
,
cfg
}
func
blockBatchRlpSize
(
t
*
testing
.
T
,
b
*
types
.
Block
)
int
{
t
.
Helper
()
batch
,
_
,
err
:=
derive
.
BlockToBatch
(
b
)
require
.
NoError
(
t
,
err
)
var
buf
bytes
.
Buffer
require
.
NoError
(
t
,
batch
.
EncodeRLP
(
&
buf
),
"RLP-encoding batch"
)
return
buf
.
Len
()
}
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