Debian Codegraph @

internal/state/state_binary_test.go

raw
1 //nolint:testpackage
2 package state
3
4 import (
5 "testing"
6
7 "github.com/stretchr/testify/require"
8 )
9
10 func TestEncodeStateUsesCompactBinaryPayload(t *testing.T) {
11 t.Parallel()
12
13 payload := encodeState(nil, State{
14 Client: ClientIdentifier{
15 CID: 1,
16 KID: 2,
17 CommonName: "test",
18 },
19 IPAddr: "127.0.0.1",
20 IPPort: "12345",
21 SessionState: sessionStateReverseMap[SessionStateAuthenticated],
22 })
23
24 require.Equal(t, []byte{
25 binaryStateVersion,
26 flagCommonName | flagIPAddrV4 | flagIPPort,
27 '3',
28 1,
29 2,
30 4, 't', 'e', 's', 't',
31 127, 0, 0, 1,
32 5, '1', '2', '3', '4', '5',
33 }, payload)
34 }