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:
DecFox 2022-08-17 12:49:11 +05:30 committed by GitHub
commit 69602abe8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 922 additions and 26 deletions

View file

@ -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")
}
})
}