(t *testing.T)
| 105 | } |
| 106 | |
| 107 | func TestProbeSNIsConcurrent(t *testing.T) { |
| 108 | addr, stop := tlsTestServer(t) |
| 109 | defer stop() |
| 110 | ip, port := hostPort(t, addr) |
| 111 | |
| 112 | in := []string{"a.com", "b.com", "c.com", "d.com", "e.com"} |
| 113 | // onResult may fire from multiple goroutines — caller is responsible |
| 114 | // for synchronising. Using atomic to keep the race detector happy. |
| 115 | var resultsSeen atomic.Int64 |
| 116 | results := ProbeSNIs(context.Background(), in, ProbeConfig{ |
| 117 | TargetIP: ip, |
| 118 | TargetPort: port, |
| 119 | Concurrency: 2, |
| 120 | }, func(Result) { resultsSeen.Add(1) }) |
| 121 | if len(results) != len(in) { |
| 122 | t.Fatalf("len: %d want %d", len(results), len(in)) |
| 123 | } |
| 124 | if int(resultsSeen.Load()) != len(in) { |
| 125 | t.Errorf("onResult callback count: %d want %d", resultsSeen.Load(), len(in)) |
| 126 | } |
| 127 | for i, r := range results { |
| 128 | if r.SNI != in[i] { |
| 129 | t.Errorf("order not preserved: [%d] %s != %s", i, r.SNI, in[i]) |
| 130 | } |
| 131 | if r.Outcome != OutcomeOK { |
| 132 | t.Errorf("%s: outcome %s err=%q", r.SNI, r.Outcome, r.Err) |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func TestRankSNIsKeepsOnlyOK(t *testing.T) { |
| 138 | in := []Result{ |
nothing calls this directly
no test coverage detected