forked from quic-go/quic-go
handshake: migrate tests away from Ginkgo (#4667)
This commit is contained in:
35
internal/handshake/handshake_helpers_test.go
Normal file
35
internal/handshake/handshake_helpers_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package handshake
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func splitHexString(t *testing.T, s string) (slice []byte) {
|
||||
t.Helper()
|
||||
for _, ss := range strings.Split(s, " ") {
|
||||
if ss[0:2] == "0x" {
|
||||
ss = ss[2:]
|
||||
}
|
||||
d, err := hex.DecodeString(ss)
|
||||
require.NoError(t, err)
|
||||
slice = append(slice, d...)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func TestSplitHexString(t *testing.T) {
|
||||
require.Equal(t, []byte{0xde, 0xad, 0xbe, 0xef}, splitHexString(t, "0xdeadbeef"))
|
||||
require.Equal(t, []byte{0xde, 0xad, 0xbe, 0xef}, splitHexString(t, "deadbeef"))
|
||||
require.Equal(t, []byte{0xde, 0xad, 0xbe, 0xef}, splitHexString(t, "dead beef"))
|
||||
}
|
||||
|
||||
var cipherSuites = []*cipherSuite{
|
||||
getCipherSuite(tls.TLS_AES_128_GCM_SHA256),
|
||||
getCipherSuite(tls.TLS_AES_256_GCM_SHA384),
|
||||
getCipherSuite(tls.TLS_CHACHA20_POLY1305_SHA256),
|
||||
}
|
||||
Reference in New Issue
Block a user