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
a1064b2a
Unverified
Commit
a1064b2a
authored
Apr 18, 2023
by
Michael de Hoog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lint
parent
7996695f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
queue_test.go
op-service/txmgr/queue_test.go
+15
-8
No files found.
op-service/txmgr/queue_test.go
View file @
a1064b2a
...
@@ -201,6 +201,7 @@ func TestSend(t *testing.T) {
...
@@ -201,6 +201,7 @@ func TestSend(t *testing.T) {
metr
:
&
metrics
.
NoopTxMetrics
{},
metr
:
&
metrics
.
NoopTxMetrics
{},
}
}
// track the nonces, and return any expected errors from tx sending
var
nonces
[]
uint64
var
nonces
[]
uint64
sendTx
:=
func
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
error
{
sendTx
:=
func
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
error
{
index
:=
int
(
tx
.
Data
()[
0
])
index
:=
int
(
tx
.
Data
()[
0
])
...
@@ -218,9 +219,7 @@ func TestSend(t *testing.T) {
...
@@ -218,9 +219,7 @@ func TestSend(t *testing.T) {
}
}
backend
.
setTxSender
(
sendTx
)
backend
.
setTxSender
(
sendTx
)
ctx
:=
context
.
Background
()
// for each factory call, create a candidate from the given test case's tx data
queue
:=
NewQueue
[
int
](
mgr
,
test
.
max
,
func
(
uint64
)
{})
txIndex
:=
0
txIndex
:=
0
factory
:=
TxFactory
[
int
](
func
(
ctx
context
.
Context
)
(
TxCandidate
,
int
,
error
)
{
factory
:=
TxFactory
[
int
](
func
(
ctx
context
.
Context
)
(
TxCandidate
,
int
,
error
)
{
var
testTx
*
testTx
var
testTx
*
testTx
...
@@ -237,6 +236,10 @@ func TestSend(t *testing.T) {
...
@@ -237,6 +236,10 @@ func TestSend(t *testing.T) {
},
txIndex
-
1
,
nil
},
txIndex
-
1
,
nil
})
})
ctx
:=
context
.
Background
()
queue
:=
NewQueue
[
int
](
mgr
,
test
.
max
,
func
(
uint64
)
{})
// make all the queue calls given in the test case
start
:=
time
.
Now
()
start
:=
time
.
Now
()
for
i
,
c
:=
range
test
.
calls
{
for
i
,
c
:=
range
test
.
calls
{
msg
:=
fmt
.
Sprintf
(
"Call %d"
,
i
)
msg
:=
fmt
.
Sprintf
(
"Call %d"
,
i
)
...
@@ -258,13 +261,17 @@ func TestSend(t *testing.T) {
...
@@ -258,13 +261,17 @@ func TestSend(t *testing.T) {
}
}
}()
}()
}
}
// wait for the queue to drain (all txs complete or failed)
queue
.
Wait
()
queue
.
Wait
()
duration
:=
time
.
Now
()
.
Sub
(
start
)
duration
:=
time
.
Since
(
start
)
require
.
Greater
(
t
,
duration
,
test
.
total
)
// expect the execution time within a certain window
require
.
Less
(
t
,
duration
,
test
.
total
+
500
*
time
.
Millisecond
)
require
.
Greater
(
t
,
duration
,
test
.
total
,
"test was faster than expected"
)
require
.
Less
(
t
,
duration
,
test
.
total
+
500
*
time
.
Millisecond
,
"test was slower than expected"
)
// check that the nonces match
slices
.
Sort
(
nonces
)
slices
.
Sort
(
nonces
)
require
.
Equal
(
t
,
test
.
nonces
,
nonces
)
require
.
Equal
(
t
,
test
.
nonces
,
nonces
,
"expected nonces do not match"
)
require
.
Equal
(
t
,
len
(
test
.
txs
),
txIndex
)
// check
require
.
Equal
(
t
,
len
(
test
.
txs
),
txIndex
,
"number of transactions sent does not match"
)
})
})
}
}
}
}
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