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
389e97fe
Commit
389e97fe
authored
Mar 14, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
err seq window close
parent
2505714f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+64
-0
No files found.
op-batcher/batcher/channel_builder_test.go
View file @
389e97fe
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"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/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
...
@@ -213,6 +214,69 @@ func FuzzChannelTimeoutCloseZeroTimeout(f *testing.F) {
...
@@ -213,6 +214,69 @@ func FuzzChannelTimeoutCloseZeroTimeout(f *testing.F) {
})
})
}
}
// FuzzSeqWindowClose ensures that the channel builder has a [ErrSeqWindowClose]
// as long as the timeout constraint is met and the builder's timeout is greater than
// the calculated timeout
func
FuzzSeqWindowClose
(
f
*
testing
.
F
)
{
// Set multiple seeds in case fuzzing isn't explicitly used
for
i
:=
range
[
10
]
int
{}
{
f
.
Add
(
uint64
(
i
),
uint64
(
i
),
uint64
(
i
),
uint64
(
i
*
5
))
}
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
epochNum
uint64
,
seqWindowSize
uint64
,
subSafetyMargin
uint64
,
timeout
uint64
)
{
// Create the channel builder
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
SeqWindowSize
=
seqWindowSize
channelConfig
.
SubSafetyMargin
=
subSafetyMargin
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
// Check the timeout
cb
.
timeout
=
timeout
cb
.
updateSwTimeout
(
&
derive
.
BatchData
{
BatchV1
:
derive
.
BatchV1
{
EpochNum
:
rollup
.
Epoch
(
epochNum
),
},
})
calculatedTimeout
:=
epochNum
+
seqWindowSize
-
subSafetyMargin
if
timeout
>
calculatedTimeout
{
cb
.
checkTimeout
(
calculatedTimeout
)
require
.
ErrorIsf
(
t
,
cb
.
FullErr
(),
ErrSeqWindowClose
,
"Sequence window close should be reached"
)
}
else
{
require
.
NoError
(
t
,
cb
.
FullErr
())
}
})
}
// FuzzSeqWindowCloseZeroTimeout ensures that the channel builder has a [ErrSeqWindowClose]
// as long as the timeout constraint is met and the builder's timeout is set to zero.
func
FuzzSeqWindowCloseZeroTimeout
(
f
*
testing
.
F
)
{
// Set multiple seeds in case fuzzing isn't explicitly used
for
i
:=
range
[
10
]
int
{}
{
f
.
Add
(
uint64
(
i
),
uint64
(
i
),
uint64
(
i
))
}
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
epochNum
uint64
,
seqWindowSize
uint64
,
subSafetyMargin
uint64
)
{
// Create the channel builder
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
SeqWindowSize
=
seqWindowSize
channelConfig
.
SubSafetyMargin
=
subSafetyMargin
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
// Check the timeout
cb
.
timeout
=
0
cb
.
updateSwTimeout
(
&
derive
.
BatchData
{
BatchV1
:
derive
.
BatchV1
{
EpochNum
:
rollup
.
Epoch
(
epochNum
),
},
})
calculatedTimeout
:=
epochNum
+
seqWindowSize
-
subSafetyMargin
cb
.
checkTimeout
(
calculatedTimeout
)
if
cb
.
timeout
!=
0
{
require
.
ErrorIsf
(
t
,
cb
.
FullErr
(),
ErrSeqWindowClose
,
"Sequence window close should be reached"
)
}
})
}
// TestBuilderNextFrame tests calling NextFrame on a ChannelBuilder with only one frame
// TestBuilderNextFrame tests calling NextFrame on a ChannelBuilder with only one frame
func
TestBuilderNextFrame
(
t
*
testing
.
T
)
{
func
TestBuilderNextFrame
(
t
*
testing
.
T
)
{
channelConfig
:=
defaultTestChannelConfig
channelConfig
:=
defaultTestChannelConfig
...
...
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