refactor: allow automatically wrap net/quic conn (#867)
See https://github.com/ooni/probe/issues/2219
This commit is contained in:
parent
e1d014e826
commit
097926c51f
12 changed files with 83 additions and 101 deletions
|
|
@ -2,6 +2,7 @@ package mocks
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -22,6 +23,32 @@ func TestTrace(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("MaybeWrapNetConn", func(t *testing.T) {
|
||||
expect := &Conn{}
|
||||
tx := &Trace{
|
||||
MockMaybeWrapNetConn: func(conn net.Conn) net.Conn {
|
||||
return expect
|
||||
},
|
||||
}
|
||||
got := tx.MaybeWrapNetConn(&Conn{})
|
||||
if got != expect {
|
||||
t.Fatal("not working as intended")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("MaybeWrapUDPLikeConn", func(t *testing.T) {
|
||||
expect := &UDPLikeConn{}
|
||||
tx := &Trace{
|
||||
MockMaybeWrapUDPLikeConn: func(conn model.UDPLikeConn) model.UDPLikeConn {
|
||||
return expect
|
||||
},
|
||||
}
|
||||
got := tx.MaybeWrapUDPLikeConn(&UDPLikeConn{})
|
||||
if got != expect {
|
||||
t.Fatal("not working as intended")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("OnDNSRoundTripForLookupHost", func(t *testing.T) {
|
||||
var called bool
|
||||
tx := &Trace{
|
||||
|
|
|
|||
Loading…
Reference in a new issue