We're currently use jafar for QA and jafar is a better mechanism, even though it is not portable outside of Linux. This self censorship mechanism was less cool and added a bunch of (also cognitive) complexity to netx. If we ever want to go down a self censorship like road, we probably want to do as little work as possible in the problem and as much work as possible inside a helper like jafar. Part of https://github.com/ooni/probe/issues/1591.
		
			
				
	
	
		
			21 lines
		
	
	
		
			479 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			479 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package dialer
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/ooni/psiphon/oopsi/golang.org/x/net/context"
 | |
| )
 | |
| 
 | |
| func TestSystemDialer(t *testing.T) {
 | |
| 	ctx, cancel := context.WithCancel(context.Background())
 | |
| 	cancel() // fail immediately
 | |
| 	conn, err := Default.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")
 | |
| 	}
 | |
| }
 |