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
42c3a29e
Commit
42c3a29e
authored
Mar 14, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timeout close
parent
081b40b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+55
-0
No files found.
op-batcher/batcher/channel_builder_test.go
View file @
42c3a29e
...
...
@@ -158,6 +158,61 @@ func FuzzDurationTimeout(f *testing.F) {
})
}
// FuzzChannelTimeoutClose ensures that the channel builder has a [ErrChannelTimeoutClose]
// as long as the timeout constraint is met and the builder's timeout is greater than
// the calculated timeout
func
FuzzChannelTimeoutClose
(
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
,
l1BlockNum
uint64
,
channelTimeout
uint64
,
subSafetyMargin
uint64
,
timeout
uint64
)
{
// Create the channel builder
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
ChannelTimeout
=
channelTimeout
channelConfig
.
SubSafetyMargin
=
subSafetyMargin
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
// Check the timeout
cb
.
timeout
=
timeout
cb
.
FramePublished
(
l1BlockNum
)
calculatedTimeout
:=
l1BlockNum
+
channelTimeout
-
subSafetyMargin
if
timeout
>
calculatedTimeout
{
cb
.
checkTimeout
(
calculatedTimeout
)
require
.
ErrorIsf
(
t
,
cb
.
FullErr
(),
ErrChannelTimeoutClose
,
"Channel timeout close should be reached"
)
}
else
{
require
.
NoError
(
t
,
cb
.
FullErr
())
}
})
}
// FuzzChannelTimeoutCloseZeroTimeout ensures that the channel builder has a [ErrChannelTimeoutClose]
// as long as the timeout constraint is met and the builder's timeout is set to zero.
func
FuzzChannelTimeoutCloseZeroTimeout
(
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
,
channelTimeout
uint64
,
subSafetyMargin
uint64
)
{
// Create the channel builder
channelConfig
:=
defaultTestChannelConfig
channelConfig
.
ChannelTimeout
=
channelTimeout
channelConfig
.
SubSafetyMargin
=
subSafetyMargin
cb
,
err
:=
newChannelBuilder
(
channelConfig
)
require
.
NoError
(
t
,
err
)
// Check the timeout
cb
.
timeout
=
0
cb
.
FramePublished
(
l1BlockNum
)
calculatedTimeout
:=
l1BlockNum
+
channelTimeout
-
subSafetyMargin
cb
.
checkTimeout
(
calculatedTimeout
)
if
cb
.
timeout
!=
0
{
require
.
ErrorIsf
(
t
,
cb
.
FullErr
(),
ErrChannelTimeoutClose
,
"Channel timeout close should be reached"
)
}
})
}
// TestBuilderNextFrame tests calling NextFrame on a ChannelBuilder with only one frame
func
TestBuilderNextFrame
(
t
*
testing
.
T
)
{
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