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
14d154d9
Unverified
Commit
14d154d9
authored
Nov 02, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: static-peers test
parent
48962ac9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
host.go
op-node/p2p/host.go
+1
-1
host_test.go
op-node/p2p/host_test.go
+11
-0
No files found.
op-node/p2p/host.go
View file @
14d154d9
...
...
@@ -236,7 +236,7 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter, metrics Host
return
nil
,
fmt
.
Errorf
(
"bad peer address: %w"
,
err
)
}
if
addr
.
ID
==
h
.
ID
()
{
log
.
Info
(
"Static-peer list contains address of local peer, ignoring the address."
,
"
address"
,
addr
)
log
.
Info
(
"Static-peer list contains address of local peer, ignoring the address."
,
"
peer_id"
,
addr
.
ID
,
"addrs"
,
addr
.
Addrs
)
continue
}
staticPeers
=
append
(
staticPeers
,
addr
)
...
...
op-node/p2p/host_test.go
View file @
14d154d9
...
...
@@ -15,6 +15,7 @@ import (
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
mocknet
"github.com/libp2p/go-libp2p/p2p/net/mock"
ma
"github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
...
...
@@ -139,6 +140,13 @@ func TestP2PFull(t *testing.T) {
confB
.
StaticPeers
,
err
=
peer
.
AddrInfoToP2pAddrs
(
&
peer
.
AddrInfo
{
ID
:
hostA
.
ID
(),
Addrs
:
hostA
.
Addrs
()})
require
.
NoError
(
t
,
err
)
// Add address of host B itself, it shouldn't connect or cause issues.
idB
,
err
:=
peer
.
IDFromPublicKey
(
confB
.
Priv
.
GetPublic
())
require
.
NoError
(
t
,
err
)
altAddrB
,
err
:=
ma
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/12345/p2p/"
+
idB
.
String
())
require
.
NoError
(
t
,
err
)
confB
.
StaticPeers
=
append
(
confB
.
StaticPeers
,
altAddrB
)
logB
:=
testlog
.
Logger
(
t
,
log
.
LvlError
)
.
New
(
"host"
,
"B"
)
nodeB
,
err
:=
NewNodeP2P
(
context
.
Background
(),
&
rollup
.
Config
{},
logB
,
&
confB
,
&
mockGossipIn
{},
nil
,
runCfgB
,
metrics
.
NoopMetrics
)
...
...
@@ -146,6 +154,9 @@ func TestP2PFull(t *testing.T) {
defer
nodeB
.
Close
()
hostB
:=
nodeB
.
Host
()
require
.
True
(
t
,
nodeB
.
IsStatic
(
hostA
.
ID
()),
"node A must be static peer of node B"
)
require
.
False
(
t
,
nodeB
.
IsStatic
(
hostB
.
ID
()),
"node B must not be static peer of node B itself"
)
select
{
case
<-
time
.
After
(
time
.
Second
)
:
t
.
Fatal
(
"failed to connect new host"
)
...
...
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