Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mf
go-multiaddr
Commits
7f59fc3f
Commit
7f59fc3f
authored
Jun 18, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for /p2p addrs
parent
a778a9db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
multiaddr_test.go
multiaddr_test.go
+25
-0
No files found.
multiaddr_test.go
View file @
7f59fc3f
...
...
@@ -45,6 +45,8 @@ func TestConstructFails(t *testing.T) {
"/ip4/127.0.0.1/quic/1234"
,
"/ip4/127.0.0.1/ipfs"
,
"/ip4/127.0.0.1/ipfs/tcp"
,
"/ip4/127.0.0.1/p2p"
,
"/ip4/127.0.0.1/p2p/tcp"
,
"/unix"
,
"/ip4/1.2.3.4/tcp/80/unix"
,
}
...
...
@@ -74,12 +76,14 @@ func TestConstructSucceeds(t *testing.T) {
"/udp/65535"
,
"/tcp/65535"
,
"/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"
,
"/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"
,
"/udp/1234/sctp/1234"
,
"/udp/1234/udt"
,
"/udp/1234/utp"
,
"/tcp/1234/http"
,
"/tcp/1234/https"
,
"/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234"
,
"/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234"
,
"/ip4/127.0.0.1/udp/1234"
,
"/ip4/127.0.0.1/udp/0"
,
"/ip4/127.0.0.1/tcp/1234"
,
...
...
@@ -87,10 +91,13 @@ func TestConstructSucceeds(t *testing.T) {
"/ip4/127.0.0.1/udp/1234/quic"
,
"/ip4/127.0.0.1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"
,
"/ip4/127.0.0.1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234"
,
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC"
,
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234"
,
"/unix/a/b/c/d/e"
,
"/unix/stdio"
,
"/ip4/1.2.3.4/tcp/80/unix/a/b/c/d/e/f"
,
"/ip4/127.0.0.1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234/unix/stdio"
,
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234/unix/stdio"
,
}
for
_
,
a
:=
range
cases
{
...
...
@@ -453,3 +460,21 @@ func TestRoundTrip(t *testing.T) {
}
}
}
// XXX: Change this test when we switch to /p2p by default.
func
TestIPFSvP2P
(
t
*
testing
.
T
)
{
var
(
p2pAddr
=
"/p2p/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP"
ipfsAddr
=
"/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP"
)
for
_
,
s
:=
range
[]
string
{
p2pAddr
,
ipfsAddr
}
{
ma
,
err
:=
NewMultiaddr
(
s
)
if
err
!=
nil
{
t
.
Errorf
(
"error when parsing %q: %s"
,
s
,
err
)
}
if
ma
.
String
()
!=
ipfsAddr
{
t
.
Errorf
(
"expected %q, got %q"
,
ipfsAddr
,
ma
.
String
())
}
}
}
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