Skip to content

Commit 8e18655

Browse files
committed
add tests for HTTP(S), WebRTCDirect; remove bad HTTP pattern.
1 parent 74e82e2 commit 8e18655

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

patterns.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var HTTP = Or(
5555
And(TCP, Base(ma.P_HTTP)),
5656
And(IP, Base(ma.P_HTTP)),
5757
And(DNS, Base(ma.P_HTTP)),
58-
And(DNS),
5958
)
6059

6160
// Define https over TCP or DNS or https over DNS format multiaddr

patterns_test.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,35 @@ var TestVectors = map[string]*testVector{
4444
"/ip4/1.2.3.4/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
4545
"/ip6/::/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
4646
"/ip6/::/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
47-
"/ip4/0.0.0.0/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"},
47+
"/ip4/0.0.0.0/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
48+
},
4849
Bad: []string{
4950
"/ip4/1.2.3.4/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
5051
"/ip6/::/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
5152
"/tcp/123/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
5253
"/ip6/::/udp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
5354
"/ip6/::/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
54-
"/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"}},
55+
"/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
56+
},
57+
},
5558
"DNS": {
5659
Pattern: DNS,
57-
Good: []string{"/dnsaddr/ipfs.io", "/dns4/ipfs.io", "/dns4/libp2p.io", "/dns6/protocol.ai"},
60+
Good: []string{"/dnsaddr/example.io", "/dns4/example.io", "/dns6/example.io"},
5861
Bad: []string{"/ip4/127.0.0.1"},
5962
},
63+
"WebRTCDirect": {
64+
Pattern: WebRTCDirect,
65+
Good: []string{"/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct", "/ip6/::/tcp/0/http/p2p-webrtc-direct"},
66+
Bad: []string{"/ip4/0.0.0.0", "/ip6/fc00::", "/udp/12345", "/ip6/fc00::/tcp/5523/udp/9543"},
67+
},
68+
"HTTP": {
69+
Pattern: HTTP,
70+
Good: []string{"/ip4/1.2.3.4/http", "/dns4/example.io/http", "/dns6/::/tcp/7011/http", "/dnsaddr/example.io/http", "/ip6/fc00::/http"},
71+
},
72+
"HTTPS": {
73+
Pattern: HTTPS,
74+
Good: []string{"/ip4/1.2.3.4/https", "/dns4/example.io/https", "/dns6/::/tcp/7011/https", "/ip6/fc00::/https"},
75+
},
6076
}
6177

6278
func TestProtocolMatching(t *testing.T) {

0 commit comments

Comments
 (0)