Commit 8e186559 authored by Raúl Kripalani's avatar Raúl Kripalani

add tests for HTTP(S), WebRTCDirect; remove bad HTTP pattern.

parent 74e82e2a
......@@ -55,7 +55,6 @@ var HTTP = Or(
And(TCP, Base(ma.P_HTTP)),
And(IP, Base(ma.P_HTTP)),
And(DNS, Base(ma.P_HTTP)),
And(DNS),
)
// Define https over TCP or DNS or https over DNS format multiaddr
......
......@@ -44,19 +44,35 @@ var TestVectors = map[string]*testVector{
"/ip4/1.2.3.4/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/0.0.0.0/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"},
"/ip4/0.0.0.0/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
},
Bad: []string{
"/ip4/1.2.3.4/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/tcp/123/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/udp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"}},
"/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
},
},
"DNS": {
Pattern: DNS,
Good: []string{"/dnsaddr/ipfs.io", "/dns4/ipfs.io", "/dns4/libp2p.io", "/dns6/protocol.ai"},
Good: []string{"/dnsaddr/example.io", "/dns4/example.io", "/dns6/example.io"},
Bad: []string{"/ip4/127.0.0.1"},
},
"WebRTCDirect": {
Pattern: WebRTCDirect,
Good: []string{"/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct", "/ip6/::/tcp/0/http/p2p-webrtc-direct"},
Bad: []string{"/ip4/0.0.0.0", "/ip6/fc00::", "/udp/12345", "/ip6/fc00::/tcp/5523/udp/9543"},
},
"HTTP": {
Pattern: HTTP,
Good: []string{"/ip4/1.2.3.4/http", "/dns4/example.io/http", "/dns6/::/tcp/7011/http", "/dnsaddr/example.io/http", "/ip6/fc00::/http"},
},
"HTTPS": {
Pattern: HTTPS,
Good: []string{"/ip4/1.2.3.4/https", "/dns4/example.io/https", "/dns6/::/tcp/7011/https", "/ip6/fc00::/https"},
},
}
func TestProtocolMatching(t *testing.T) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment