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
e79b17c6
Commit
e79b17c6
authored
Mar 13, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
frame publishing tests
parent
53d9465e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
channel_builder_test.go
op-batcher/batcher/channel_builder_test.go
+82
-0
No files found.
op-batcher/batcher/channel_builder_test.go
View file @
e79b17c6
...
@@ -242,3 +242,85 @@ func (testSuite *ChannelBuilderTestSuite) TestBuilderReset() {
...
@@ -242,3 +242,85 @@ func (testSuite *ChannelBuilderTestSuite) TestBuilderReset() {
testSuite
.
Equal
(
0
,
cb
.
co
.
InputBytes
())
testSuite
.
Equal
(
0
,
cb
.
co
.
InputBytes
())
testSuite
.
Equal
(
0
,
cb
.
co
.
ReadyBytes
())
testSuite
.
Equal
(
0
,
cb
.
co
.
ReadyBytes
())
}
}
// TestBuilderRegisterL1Block tests the RegisterL1Block function
func
(
testSuite
*
ChannelBuilderTestSuite
)
TestBuilderRegisterL1Block
()
{
// Construct the channel builder
cb
,
err
:=
newChannelBuilder
(
testSuite
.
channelConfig
)
testSuite
.
NoError
(
err
)
// Assert params modified in RegisterL1Block
testSuite
.
Equal
(
uint64
(
1
),
testSuite
.
channelConfig
.
MaxChannelDuration
)
testSuite
.
Equal
(
uint64
(
0
),
cb
.
timeout
)
// Register a new L1 block
cb
.
RegisterL1Block
(
uint64
(
100
))
// Assert params modified in RegisterL1Block
testSuite
.
Equal
(
uint64
(
1
),
testSuite
.
channelConfig
.
MaxChannelDuration
)
testSuite
.
Equal
(
uint64
(
101
),
cb
.
timeout
)
}
// TestBuilderRegisterL1BlockZeroMaxChannelDuration tests the RegisterL1Block function
func
(
testSuite
*
ChannelBuilderTestSuite
)
TestBuilderRegisterL1BlockZeroMaxChannelDuration
()
{
// Set the max channel duration to 0
testSuite
.
channelConfig
.
MaxChannelDuration
=
0
// Construct the channel builder
cb
,
err
:=
newChannelBuilder
(
testSuite
.
channelConfig
)
testSuite
.
NoError
(
err
)
// Assert params modified in RegisterL1Block
testSuite
.
Equal
(
uint64
(
0
),
testSuite
.
channelConfig
.
MaxChannelDuration
)
testSuite
.
Equal
(
uint64
(
0
),
cb
.
timeout
)
// Register a new L1 block
cb
.
RegisterL1Block
(
uint64
(
100
))
// Since the max channel duration is set to 0,
// the L1 block register should not update the timeout
testSuite
.
Equal
(
uint64
(
0
),
testSuite
.
channelConfig
.
MaxChannelDuration
)
testSuite
.
Equal
(
uint64
(
0
),
cb
.
timeout
)
}
// TestFramePublished tests the FramePublished function
func
(
testSuite
*
ChannelBuilderTestSuite
)
TestFramePublished
()
{
// Construct the channel builder
cb
,
err
:=
newChannelBuilder
(
testSuite
.
channelConfig
)
testSuite
.
NoError
(
err
)
// Let's say the block number is fed in as 100
// and the channel timeout is 1000
l1BlockNum
:=
uint64
(
100
)
cb
.
cfg
.
ChannelTimeout
=
uint64
(
1000
)
cb
.
cfg
.
SubSafetyMargin
=
100
// Then the frame published will update the timeout
cb
.
FramePublished
(
l1BlockNum
)
// Now the timeout will be 1000
testSuite
.
Equal
(
uint64
(
1000
),
cb
.
timeout
)
}
// TestFramePublishedUnderflows tests the FramePublished function
//
// Realistically, this will not happen because the [ChannelTimeout] is _known_
// to be greater than the [SubSafetyMargin] when the ChannelConfig is configured
// via cli flags / environment variables.
func
(
testSuite
*
ChannelBuilderTestSuite
)
TestFramePublishedUnderflows
()
{
// Construct the channel builder
cb
,
err
:=
newChannelBuilder
(
testSuite
.
channelConfig
)
testSuite
.
NoError
(
err
)
// Let's say the block number is fed in as 0
// and the channel timeout is < the sub safety margin
l1BlockNum
:=
uint64
(
0
)
cb
.
cfg
.
ChannelTimeout
=
uint64
(
1
)
cb
.
cfg
.
SubSafetyMargin
=
uint64
(
2
)
// Then the frame published will underflow the timeout
cb
.
FramePublished
(
l1BlockNum
)
// Now the timeout will be the max uint64
testSuite
.
Equal
(
uint64
(
0xffffffffffffffff
),
cb
.
timeout
)
}
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