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
f2aef6df
Commit
f2aef6df
authored
Jun 08, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: TestChannelBankInterleaved
parent
129032f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
channel_bank_test.go
op-node/rollup/derive/channel_bank_test.go
+64
-0
No files found.
op-node/rollup/derive/channel_bank_test.go
View file @
f2aef6df
...
...
@@ -129,6 +129,70 @@ func TestChannelBankSimple(t *testing.T) {
require
.
Equal
(
t
,
io
.
EOF
,
err
)
}
// TestChannelBankInterleaved ensure that the channel bank can handle frames from multiple channels
// that arrive out of order. Per the specs, the first channel to arrive (not the first to be completed)
// is returned first.
func
TestChannelBankInterleaved
(
t
*
testing
.
T
)
{
rng
:=
rand
.
New
(
rand
.
NewSource
(
1234
))
a
:=
testutils
.
RandomBlockRef
(
rng
)
input
:=
&
fakeChannelBankInput
{
origin
:
a
}
input
.
AddFrames
(
"a:0:first"
,
"b:2:trois!"
)
input
.
AddFrames
(
"b:1:deux"
,
"a:2:third!"
)
input
.
AddFrames
(
"b:0:premiere"
)
input
.
AddFrames
(
"a:1:second"
)
input
.
AddFrame
(
Frame
{},
io
.
EOF
)
cfg
:=
&
rollup
.
Config
{
ChannelTimeout
:
10
}
cb
:=
NewChannelBank
(
testlog
.
Logger
(
t
,
log
.
LvlCrit
),
cfg
,
input
,
nil
)
// Load a:0
out
,
err
:=
cb
.
NextData
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
NotEnoughData
)
require
.
Equal
(
t
,
[]
byte
(
nil
),
out
)
// Load b:2
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
NotEnoughData
)
require
.
Equal
(
t
,
[]
byte
(
nil
),
out
)
// Load b:1
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
NotEnoughData
)
require
.
Equal
(
t
,
[]
byte
(
nil
),
out
)
// Load a:2
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
NotEnoughData
)
require
.
Equal
(
t
,
[]
byte
(
nil
),
out
)
// Load b:0 & Channel b is complete, but channel a was opened first
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
NotEnoughData
)
require
.
Equal
(
t
,
[]
byte
(
nil
),
out
)
// Load a:1
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
ErrorIs
(
t
,
err
,
NotEnoughData
)
require
.
Equal
(
t
,
[]
byte
(
nil
),
out
)
// Pull out the channel a
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
"firstsecondthird"
,
string
(
out
))
// Pull out the channel b
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
"premieredeuxtrois"
,
string
(
out
))
// No more data
out
,
err
=
cb
.
NextData
(
context
.
Background
())
require
.
Nil
(
t
,
out
)
require
.
Equal
(
t
,
io
.
EOF
,
err
)
}
func
TestChannelBankDuplicates
(
t
*
testing
.
T
)
{
rng
:=
rand
.
New
(
rand
.
NewSource
(
1234
))
a
:=
testutils
.
RandomBlockRef
(
rng
)
...
...
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