refactor(netxlite): adapt single-use-quic-dialer from websteps (#472)
This is the last bit of functionality we need before rewriting a chunk of websteps to use netxlite. To rewrite most of it, we still need to move over: 1. dnstransport code 2. errorsx code With both done, netxlite is a good library for websteps as well as for most other operations we perform outside of the experiments. Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
b9c4ad0b2b
commit
fe3c90479d
3 changed files with 58 additions and 1 deletions
|
|
@ -460,3 +460,26 @@ func TestNewQUICDialerWithoutResolverChain(t *testing.T) {
|
|||
t.Fatal("invalid quic listener")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewSingleUseQUICDialerWorksAsIntended(t *testing.T) {
|
||||
sess := &mocks.QUICEarlySession{}
|
||||
qd := NewSingleUseQUICDialer(sess)
|
||||
outsess, err := qd.DialContext(
|
||||
context.Background(), "", "", &tls.Config{}, &quic.Config{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if sess != outsess {
|
||||
t.Fatal("invalid outsess")
|
||||
}
|
||||
for i := 0; i < 4; i++ {
|
||||
outsess, err = qd.DialContext(
|
||||
context.Background(), "", "", &tls.Config{}, &quic.Config{})
|
||||
if !errors.Is(err, ErrNoConnReuse) {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
if outsess != nil {
|
||||
t.Fatal("expected nil outconn here")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue