-
Notifications
You must be signed in to change notification settings - Fork 79
/
chunk_init_test.go
35 lines (28 loc) · 1.26 KB
/
chunk_init_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
34
35
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package sctp
import (
"testing"
)
func TestChunkInit_UnrecognizedParameters(t *testing.T) {
initChunkHeader := []byte{
0x55, 0xb9, 0x64, 0xa5, 0x00, 0x02, 0x00, 0x00,
0x04, 0x00, 0x08, 0x00, 0xe8, 0x6d, 0x10, 0x30,
}
unrecognizedSkip := append([]byte{}, initChunkHeader...)
unrecognizedSkip = append(unrecognizedSkip, byte(paramHeaderUnrecognizedActionSkip), 0xFF, 0x00, 0x04, 0x00)
i := &chunkInitCommon{}
if err := i.unmarshal(unrecognizedSkip); err != nil {
t.Errorf("Unmarshal init Chunk failed: %v", err)
} else if len(i.unrecognizedParams) != 1 || i.unrecognizedParams[0].unrecognizedAction != paramHeaderUnrecognizedActionSkip {
t.Errorf("Unrecognized Param parsed incorrectly")
}
unrecognizedStop := append([]byte{}, initChunkHeader...)
unrecognizedStop = append(unrecognizedStop, byte(paramHeaderUnrecognizedActionStop), 0xFF, 0x00, 0x04, 0x00)
i = &chunkInitCommon{}
if err := i.unmarshal(unrecognizedStop); err != nil {
t.Errorf("Unmarshal init Chunk failed: %v", err)
} else if len(i.unrecognizedParams) != 1 || i.unrecognizedParams[0].unrecognizedAction != paramHeaderUnrecognizedActionStop {
t.Errorf("Unrecognized Param parsed incorrectly")
}
}