* refactor(netx/dialer): hide implementation complexity This follows the blueprint of `module.Config` and `nodule.New` described at https://github.com/ooni/probe/issues/1591. * fix: ndt7 bug where we were not using the right resolver * fix(legacy/netx): clarify irrelevant implementation change * fix: improve comments * fix(hhfm): do not use dialer.New b/c it breaks it Unclear to me why this is happening. Still, improve upon the previous situation by adding a timeout. It does not seem a priority to look into this issue now.
		
			
				
	
	
		
			29 lines
		
	
	
		
			658 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			658 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package dialer
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| 	"time"
 | |
| 
 | |
| 	"github.com/ooni/psiphon/oopsi/golang.org/x/net/context"
 | |
| )
 | |
| 
 | |
| func TestSystemDialerWorks(t *testing.T) {
 | |
| 	ctx, cancel := context.WithCancel(context.Background())
 | |
| 	cancel() // fail immediately
 | |
| 	conn, err := systemDialer.DialContext(ctx, "tcp", "8.8.8.8:853")
 | |
| 	if err == nil || !strings.HasSuffix(err.Error(), "operation was canceled") {
 | |
| 		t.Fatal("not the error we expected", err)
 | |
| 	}
 | |
| 	if conn != nil {
 | |
| 		t.Fatal("expected nil conn here")
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func TestSystemDialerHasTimeout(t *testing.T) {
 | |
| 	expected := 15 * time.Second
 | |
| 	if systemDialer.Timeout != expected {
 | |
| 		t.Fatal("unexpected timeout value")
 | |
| 	}
 | |
| }
 |