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
2837d354
Commit
2837d354
authored
Sep 08, 2022
by
Marco Munizaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document other behaviors
parent
9320261c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
interface.go
interface.go
+2
-0
multiaddr_test.go
multiaddr_test.go
+10
-0
No files found.
interface.go
View file @
2837d354
...
...
@@ -50,6 +50,8 @@ type Multiaddr interface {
// Decapsulate removes a Multiaddr wrapping. For example:
//
// /ip4/1.2.3.4/tcp/80 decapsulate /tcp/80 = /ip4/1.2.3.4
// /ip4/1.2.3.4/tcp/80 decapsulate /udp/80 = /ip4/1.2.3.4/tcp/80
// /ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = nil
//
Decapsulate
(
Multiaddr
)
Multiaddr
...
...
multiaddr_test.go
View file @
2837d354
...
...
@@ -434,6 +434,16 @@ func TestDecapsulateComment(t *testing.T) {
if
rest
.
String
()
!=
"/ip4/1.2.3.4"
{
t
.
Fatalf
(
"Documented behavior is not correct. Expected %v saw %v"
,
"/ip4/1.2.3.4/"
,
rest
.
String
())
}
m
=
StringCast
(
"/ip4/1.2.3.4/tcp/80"
)
rest
=
m
.
Decapsulate
(
StringCast
(
"/udp/80"
))
if
!
rest
.
Equal
(
m
)
{
t
.
Fatalf
(
"Documented behavior is not correct. Expected %v saw %v"
,
"/ip4/1.2.3.4/tcp/80"
,
rest
.
String
())
}
m
=
StringCast
(
"/ip4/1.2.3.4/tcp/80"
)
rest
=
m
.
Decapsulate
(
StringCast
(
"/ip4/1.2.3.4"
))
require
.
Nil
(
t
,
rest
,
"expected a nil multiaddr if we decapsulate everything"
)
}
func
assertValueForProto
(
t
*
testing
.
T
,
a
Multiaddr
,
p
int
,
exp
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