-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmessage_test.go
33 lines (26 loc) · 879 Bytes
/
message_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package doubleratchet
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestMessageHeader_EncodeAndDecode(t *testing.T) {
// Arrange.
mh := MessageHeader{
DH: Key{0xe3, 0xbe, 0xb9, 0x4e, 0x70, 0x17, 0x37, 0xc, 0x1, 0x8f, 0xa9, 0x7e, 0xef, 0x4, 0xfb, 0x23, 0xac, 0xea, 0x28, 0xf7, 0xa9, 0x56, 0xcc, 0x1d, 0x46, 0xf3, 0xb5, 0x1d, 0x7d, 0x7d, 0x5e, 0x2c},
N: uint32(10),
PN: uint32(15),
}
// Act.
decoded, err := mh.Encode().Decode()
// Assert.
require.Nil(t, err)
require.Equal(t, mh, decoded)
}
func TestMessageEncHeader_Decode(t *testing.T) {
// Arrange.
mhe := MessageEncHeader{0xe3, 0xbe, 0xb9, 0x4e, 0x70, 0x17, 0x37, 0xc, 0x1, 0x8f, 0xa9, 0x7e, 0xef, 0x4, 0xfb, 0x23, 0xac, 0xea, 0x28, 0xf7, 0xa9, 0x56, 0xcc, 0x1d, 0x46, 0xf3, 0xb5, 0x1d, 0x7d, 0x7d, 0x5e, 0x2c}
// Act.
_, err := mhe.Decode()
// Assert.
require.NotNil(t, err)
}