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
081b40b2
Commit
081b40b2
authored
Mar 14, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
err max duration reached :test_tube:
parent
afa25281
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+80
-0
No files found.
op-batcher/batcher/channel_builder_test.go
View file @
081b40b2
...
@@ -78,6 +78,86 @@ func buildTooLargeRlpEncodedBlockBatch(cb *channelBuilder) error {
...
@@ -78,6 +78,86 @@ func buildTooLargeRlpEncodedBlockBatch(cb *channelBuilder) error {
return
err
return
err
}
}
// FuzzDurationTimeoutZeroMaxChannelDuration ensures that when whenever the MaxChannelDuration
// is set to 0, the channel builder cannot have a duration timeout.
func
FuzzDurationTimeoutZeroMaxChannelDuration
(
f
*
testing
.
F
)
{
for
i
:=
range
[
10
]
int
{}
{
f
.
Add
(
uint64
(
i
))
}
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
l1BlockNum
uint64
)
{
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
MaxChannelDuration
=
0
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
cb
.
timeout
=
0
cb
.
updateDurationTimeout
(
l1BlockNum
)
require
.
False
(
t
,
cb
.
TimedOut
(
l1BlockNum
))
})
}
// FuzzDuration ensures that when whenever the MaxChannelDuration
// is not set to 0, the channel builder will always have a duration timeout
// as long as the channel builder's timeout is set to 0.
func
FuzzDuration
(
f
*
testing
.
F
)
{
for
i
:=
range
[
10
]
int
{}
{
f
.
Add
(
uint64
(
i
),
uint64
(
i
))
}
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
l1BlockNum
uint64
,
maxChannelDuration
uint64
)
{
if
maxChannelDuration
==
0
{
t
.
Skip
(
"Max channel duration cannot be 0"
)
}
// Create the channel builder
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
MaxChannelDuration
=
maxChannelDuration
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
// Whenever the timeout is set to 0, the channel builder should have a duration timeout
cb
.
timeout
=
0
cb
.
updateDurationTimeout
(
l1BlockNum
)
cb
.
checkTimeout
(
l1BlockNum
+
maxChannelDuration
)
require
.
ErrorIsf
(
t
,
cb
.
FullErr
(),
ErrMaxDurationReached
,
"Max channel duration should be reached"
)
})
}
// FuzzDurationTimeout ensures that when whenever the MaxChannelDuration
// is not set to 0, the channel builder will always have a duration timeout
// as long as the channel builder's timeout is greater than the target block number.
func
FuzzDurationTimeout
(
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
,
l1BlockNum
uint64
,
maxChannelDuration
uint64
,
timeout
uint64
)
{
if
maxChannelDuration
==
0
{
t
.
Skip
(
"Max channel duration cannot be 0"
)
}
// Create the channel builder
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
MaxChannelDuration
=
maxChannelDuration
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
// Whenever the timeout is greater than the l1BlockNum,
// the channel builder should have a duration timeout
cb
.
timeout
=
timeout
cb
.
updateDurationTimeout
(
l1BlockNum
)
if
timeout
>
l1BlockNum
+
maxChannelDuration
{
// Notice: we cannot call this outside of the if statement
// because it would put the channel builder in an invalid state.
// That is, where the channel builder has a value set for the timeout
// with no timeoutReason. This subsequently causes a panic when
// a nil timeoutReason is used as an error (eg when calling FullErr).
cb
.
checkTimeout
(
l1BlockNum
+
maxChannelDuration
)
require
.
ErrorIsf
(
t
,
cb
.
FullErr
(),
ErrMaxDurationReached
,
"Max channel duration should be reached"
)
}
else
{
require
.
NoError
(
t
,
cb
.
FullErr
())
}
})
}
// 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