Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
a36d3834
Commit
a36d3834
authored
6 years ago
by
Steven Allen
Browse files
Options
Download
Email Patches
Plain Diff
add tests for NoTransports and NoListen
parent
ad5b7b9b
master
2018-Q4-OKR
fix/473
fix/no-custom-field
multistream-ping
punching
v6.0.23
v6.0.22
v6.0.21
v6.0.20
v6.0.19
v6.0.18
v6.0.17
v6.0.16
v6.0.15
v6.0.14
v6.0.13
v6.0.12
v6.0.11
v6.0.10
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libp2p_test.go
+36
-0
libp2p_test.go
options.go
+2
-2
options.go
with
38 additions
and
2 deletions
+38
-2
libp2p_test.go
View file @
a36d3834
...
...
@@ -9,6 +9,7 @@ import (
crypto
"github.com/libp2p/go-libp2p-crypto"
host
"github.com/libp2p/go-libp2p-host"
pstore
"github.com/libp2p/go-libp2p-peerstore"
"github.com/libp2p/go-tcp-transport"
)
...
...
@@ -32,6 +33,41 @@ func TestBadTransportConstructor(t *testing.T) {
}
}
func
TestNoListenAddrs
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
h
,
err
:=
New
(
ctx
,
NoListenAddrs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
h
.
Close
()
if
len
(
h
.
Addrs
())
!=
0
{
t
.
Fatal
(
"expected no addresses"
)
}
}
func
TestNoTransports
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
a
,
err
:=
New
(
ctx
,
NoTransports
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
a
.
Close
()
b
,
err
:=
New
(
ctx
,
ListenAddrStrings
(
"/ip4/127.0.0.1/tcp/0"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
b
.
Close
()
err
=
a
.
Connect
(
ctx
,
pstore
.
PeerInfo
{
ID
:
b
.
ID
(),
Addrs
:
b
.
Addrs
(),
})
if
err
==
nil
{
t
.
Error
(
"dial should have failed as no transports have been configured"
)
}
}
func
TestInsecure
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
h
,
err
:=
New
(
ctx
,
NoSecurity
)
...
...
This diff is collapsed.
Click to expand it.
options.go
View file @
a36d3834
...
...
@@ -242,11 +242,11 @@ func NATManager(nm config.NATManagerC) Option {
}
}
// NoListen will configure libp2p to not listen by default.
// NoListen
Addrs
will configure libp2p to not listen by default.
//
// This will both clear any configured listen addrs and prevent libp2p from
// applying the default listen address option.
var
NoListen
=
func
(
cfg
*
Config
)
error
{
var
NoListen
Addrs
=
func
(
cfg
*
Config
)
error
{
cfg
.
ListenAddrs
=
[]
ma
.
Multiaddr
{}
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help