Skip to content

Commit 9320261

Browse files
committed
Fix comment on Decapsulate
1 parent e8c0913 commit 9320261

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

interface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ type Multiaddr interface {
4747
//
4848
Encapsulate(Multiaddr) Multiaddr
4949

50-
// Decapsultate removes a Multiaddr wrapping. For example:
50+
// Decapsulate removes a Multiaddr wrapping. For example:
5151
//
52-
// /ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = /tcp/80
52+
// /ip4/1.2.3.4/tcp/80 decapsulate /tcp/80 = /ip4/1.2.3.4
5353
//
5454
Decapsulate(Multiaddr) Multiaddr
5555

multiaddr_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,15 @@ func TestEncapsulate(t *testing.T) {
427427
}
428428
}
429429

430+
func TestDecapsulateComment(t *testing.T) {
431+
// shows the behavior from the interface comment
432+
m := StringCast("/ip4/1.2.3.4/tcp/80")
433+
rest := m.Decapsulate(StringCast("/tcp/80"))
434+
if rest.String() != "/ip4/1.2.3.4" {
435+
t.Fatalf("Documented behavior is not correct. Expected %v saw %v", "/ip4/1.2.3.4/", rest.String())
436+
}
437+
}
438+
430439
func assertValueForProto(t *testing.T, a Multiaddr, p int, exp string) {
431440
t.Logf("checking for %s in %s", ProtocolWithCode(p).Name, a)
432441
fv, err := a.ValueForProtocol(p)

0 commit comments

Comments
 (0)