@ -38,7 +38,7 @@ func TestBasic(t *testing.T) {
c := newTestClient ( t )
c := newTestClient ( t )
ctx , cancel := context . With Timeout ( context . Background ( ) , 1 * time . Second )
ctx , cancel := context . With Cancel ( context . Background ( ) )
defer cancel ( )
defer cancel ( )
if err := c . Standalone ( ctx , "127.0.0.1:0" ) ; err != nil {
if err := c . Standalone ( ctx , "127.0.0.1:0" ) ; err != nil {
@ -117,7 +117,7 @@ func TestWorksWhenUDPBlocked(t *testing.T) {
c := newTestClient ( t )
c := newTestClient ( t )
ctx , cancel := context . With Timeout ( context . Background ( ) , 250 * time . Millisecond )
ctx , cancel := context . With Cancel ( context . Background ( ) )
defer cancel ( )
defer cancel ( )
r , err := c . GetReport ( ctx , dm , nil )
r , err := c . GetReport ( ctx , dm , nil )
@ -872,3 +872,30 @@ func TestReportTimeouts(t *testing.T) {
t . Errorf ( "ReportTimeout (%v) cannot be less than httpsProbeTimeout (%v)" , ReportTimeout , httpsProbeTimeout )
t . Errorf ( "ReportTimeout (%v) cannot be less than httpsProbeTimeout (%v)" , ReportTimeout , httpsProbeTimeout )
}
}
}
}
func TestNoUDPNilGetReportOpts ( t * testing . T ) {
blackhole , err := net . ListenPacket ( "udp4" , "127.0.0.1:0" )
if err != nil {
t . Fatalf ( "failed to open blackhole STUN listener: %v" , err )
}
defer blackhole . Close ( )
dm := stuntest . DERPMapOf ( blackhole . LocalAddr ( ) . String ( ) )
for _ , region := range dm . Regions {
for _ , n := range region . Nodes {
n . STUNOnly = false // exercise ICMP & HTTPS probing
}
}
c := newTestClient ( t )
ctx , cancel := context . WithCancel ( context . Background ( ) )
defer cancel ( )
r , err := c . GetReport ( ctx , dm , nil )
if err != nil {
t . Fatal ( err )
}
if r . UDP {
t . Fatal ( "unexpected working UDP" )
}
}