@@ -38,6 +38,20 @@ func assertMismatches(t *testing.T, p Pattern, args ...[]string) {
38
38
}
39
39
40
40
func TestBasicMatching (t * testing.T ) {
41
+ good_dns := []string {
42
+ "/dnsaddr/ipfs.io" ,
43
+ "/dns4/ipfs.io" ,
44
+ "/dns4/libp2p.io" ,
45
+ "/dns6/protocol.ai" ,
46
+ "/dns4/protocol.ai/tcp/80" ,
47
+ "/dns6/protocol.ai/tcp/80" ,
48
+ "/dnsaddr/protocol.ai/tcp/8" ,
49
+ }
50
+
51
+ bad_dns := []string {
52
+ "/ip4/127.0.0.1" ,
53
+ }
54
+
41
55
good_ip := []string {
42
56
"/ip4/0.0.0.0" ,
43
57
"/ip6/fc00::" ,
@@ -90,6 +104,11 @@ func TestBasicMatching(t *testing.T) {
90
104
"/quic" ,
91
105
}
92
106
107
+ good_webrtcdirect := []string {
108
+ "/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct" ,
109
+ "/ip6/::/tcp/0/http/p2p-webrtc-direct" ,
110
+ }
111
+
93
112
good_ipfs := []string {
94
113
"/ip4/1.2.3.4/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" ,
95
114
"/ip6/::/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" ,
@@ -106,6 +125,9 @@ func TestBasicMatching(t *testing.T) {
106
125
"/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" ,
107
126
}
108
127
128
+ assertMatches (t , DNS , good_dns )
129
+ assertMismatches (t , DNS , bad_dns , bad_ip )
130
+
109
131
assertMatches (t , IP , good_ip )
110
132
assertMismatches (t , IP , bad_ip , good_tcp )
111
133
@@ -127,6 +149,9 @@ func TestBasicMatching(t *testing.T) {
127
149
assertMatches (t , Unreliable , good_udp )
128
150
assertMismatches (t , Unreliable , good_ip , good_tcp , good_utp , good_ipfs , good_quic )
129
151
152
+ assertMatches (t , WebRTCDirect , good_webrtcdirect )
153
+ assertMismatches (t , WebRTCDirect , good_ip , good_udp )
154
+
130
155
assertMatches (t , IPFS , good_ipfs )
131
156
assertMismatches (t , IPFS , bad_ipfs , good_ip , good_tcp , good_utp , good_udp , good_quic )
132
157
}
0 commit comments