35 lines
880 B
Go
35 lines
880 B
Go
package doubleratchet
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
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)
|
|
}
|