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
a17bed9e
Unverified
Commit
a17bed9e
authored
Apr 04, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: remove sync test timeouts for CI
parent
4b144088
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
48 deletions
+22
-48
sync_test.go
op-node/p2p/sync_test.go
+22
-48
No files found.
op-node/p2p/sync_test.go
View file @
a17bed9e
...
@@ -2,10 +2,8 @@ package p2p
...
@@ -2,10 +2,8 @@ package p2p
import
(
import
(
"context"
"context"
"math"
"math/big"
"math/big"
"testing"
"testing"
"time"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/network"
...
@@ -13,13 +11,14 @@ import (
...
@@ -13,13 +11,14 @@ import (
mocknet
"github.com/libp2p/go-libp2p/p2p/net/mock"
mocknet
"github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
)
type
mockPayloadFn
func
(
n
uint64
)
(
*
eth
.
ExecutionPayload
,
error
)
type
mockPayloadFn
func
(
n
uint64
)
(
*
eth
.
ExecutionPayload
,
error
)
...
@@ -120,18 +119,12 @@ func TestSinglePeerSync(t *testing.T) {
...
@@ -120,18 +119,12 @@ func TestSinglePeerSync(t *testing.T) {
require
.
NoError
(
t
,
cl
.
RequestL2Range
(
ctx
,
l2Ref
(
10
),
l2Ref
(
20
)))
require
.
NoError
(
t
,
cl
.
RequestL2Range
(
ctx
,
l2Ref
(
10
),
l2Ref
(
20
)))
// and wait for the sync results to come in (in reverse order)
// and wait for the sync results to come in (in reverse order)
receiveCtx
,
receiveCancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Second
*
5
)
defer
receiveCancel
()
for
i
:=
uint64
(
19
);
i
>
10
;
i
--
{
for
i
:=
uint64
(
19
);
i
>
10
;
i
--
{
select
{
p
:=
<-
received
case
p
:=
<-
received
:
require
.
Equal
(
t
,
uint64
(
p
.
BlockNumber
),
i
,
"expecting payloads in order"
)
require
.
Equal
(
t
,
uint64
(
p
.
BlockNumber
),
i
,
"expecting payloads in order"
)
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
case
<-
receiveCtx
.
Done
()
:
t
.
Fatal
(
"did not receive all expected payloads within expected time"
)
}
}
}
}
}
...
@@ -202,34 +195,20 @@ func TestMultiPeerSync(t *testing.T) {
...
@@ -202,34 +195,20 @@ func TestMultiPeerSync(t *testing.T) {
// With such large range to request we are going to hit the rate-limits of B and C,
// With such large range to request we are going to hit the rate-limits of B and C,
// but that means we'll balance the work between the peers.
// but that means we'll balance the work between the peers.
p
:=
<-
recvA
// wait for the results to come in, based on the expected rate limit, divided by 2 (because we have 2 servers), with a buffer of 2 seconds
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
receiveCtx
,
receiveCancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Second
*
time
.
Duration
(
math
.
Ceil
(
float64
((
89
-
10
)
/
peerServerBlocksRateLimit
)))
/
2
+
time
.
Second
*
2
)
require
.
True
(
t
,
ok
,
"expecting known payload"
)
defer
receiveCancel
()
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
for
i
:=
uint64
(
89
);
i
>
10
;
i
--
{
select
{
case
p
:=
<-
recvA
:
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
case
<-
receiveCtx
.
Done
()
:
t
.
Fatal
(
"did not receive all expected payloads within expected time"
)
}
}
// now see if B can sync a range, and fill the gap with a re-request
// now see if B can sync a range, and fill the gap with a re-request
bl25
:=
payloads
[
25
]
// temporarily remove it from the available payloads. This will create a gap
bl25
:=
payloads
[
25
]
// temporarily remove it from the available payloads. This will create a gap
delete
(
payloads
,
uint64
(
25
))
delete
(
payloads
,
uint64
(
25
))
require
.
NoError
(
t
,
clB
.
RequestL2Range
(
ctx
,
l2Ref
(
20
),
l2Ref
(
30
)))
require
.
NoError
(
t
,
clB
.
RequestL2Range
(
ctx
,
l2Ref
(
20
),
l2Ref
(
30
)))
for
i
:=
uint64
(
29
);
i
>
25
;
i
--
{
for
i
:=
uint64
(
29
);
i
>
25
;
i
--
{
select
{
p
:=
<-
recvB
case
p
:=
<-
recvB
:
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
case
<-
receiveCtx
.
Done
()
:
t
.
Fatal
(
"did not receive all expected payloads within expected time"
)
}
}
}
// the request for 25 should fail. See:
// the request for 25 should fail. See:
// server: WARN peer requested unknown block by number num=25
// server: WARN peer requested unknown block by number num=25
...
@@ -239,16 +218,11 @@ func TestMultiPeerSync(t *testing.T) {
...
@@ -239,16 +218,11 @@ func TestMultiPeerSync(t *testing.T) {
payloads
[
25
]
=
bl25
payloads
[
25
]
=
bl25
// And request a range again, 25 is there now, and 21-24 should follow quickly (some may already have been fetched and wait in quarantine)
// And request a range again, 25 is there now, and 21-24 should follow quickly (some may already have been fetched and wait in quarantine)
require
.
NoError
(
t
,
clB
.
RequestL2Range
(
ctx
,
l2Ref
(
20
),
l2Ref
(
26
)))
require
.
NoError
(
t
,
clB
.
RequestL2Range
(
ctx
,
l2Ref
(
20
),
l2Ref
(
26
)))
receiveCtx
,
receiveCancel
=
context
.
WithTimeout
(
ctx
,
time
.
Second
*
10
)
defer
receiveCancel
()
for
i
:=
uint64
(
25
);
i
>
20
;
i
--
{
for
i
:=
uint64
(
25
);
i
>
20
;
i
--
{
select
{
p
:=
<-
recvB
case
p
:=
<-
recvB
:
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
exp
,
ok
:=
payloads
[
uint64
(
p
.
BlockNumber
)]
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
True
(
t
,
ok
,
"expecting known payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
require
.
Equal
(
t
,
exp
.
BlockHash
,
p
.
BlockHash
,
"expecting the correct payload"
)
case
<-
receiveCtx
.
Done
()
:
t
.
Fatal
(
"did not receive all expected payloads within expected time"
)
}
}
}
}
}
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