refactor(simplequicping): use step-by-step (#852)
See https://github.com/ooni/probe/issues/2159 and https://github.com/ooni/spec/pull/254
This commit is contained in:
parent
fbd7cd2b7e
commit
69602abe8a
16 changed files with 922 additions and 26 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
|
|
@ -95,4 +96,37 @@ func TestTrace(t *testing.T) {
|
|||
t.Fatal("not called")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("OnQUICHandshakeStart", func(t *testing.T) {
|
||||
var called bool
|
||||
tx := &Trace{
|
||||
MockOnQUICHandshakeStart: func(now time.Time, remoteAddrs string, config *quic.Config) {
|
||||
called = true
|
||||
},
|
||||
}
|
||||
tx.OnQUICHandshakeStart(time.Now(), "1.1.1.1:443", &quic.Config{})
|
||||
if !called {
|
||||
t.Fatal("not called")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("OnQUICHandshakeDone", func(t *testing.T) {
|
||||
var called bool
|
||||
tx := &Trace{
|
||||
MockOnQUICHandshakeDone: func(started time.Time, remoteAddr string, qconn quic.EarlyConnection, config *tls.Config, err error, finished time.Time) {
|
||||
called = true
|
||||
},
|
||||
}
|
||||
tx.OnQUICHandshakeDone(
|
||||
time.Now(),
|
||||
"1.1.1.1:443",
|
||||
nil,
|
||||
&tls.Config{},
|
||||
nil,
|
||||
time.Now(),
|
||||
)
|
||||
if !called {
|
||||
t.Fatal("not called")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue