forked from omec-project/pfcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_test.go
69 lines (56 loc) · 1.65 KB
/
header_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2019 free5GC.org
//
// SPDX-License-Identifier: Apache-2.0
//
package pfcp_test
import (
"encoding/hex"
"testing"
"github.com/stretchr/testify/assert"
"github.com/free5gc/pfcp"
)
const (
NodeRelatedHeaderHex = "2005000000000100"
SessionRelatedHeaderHex = "233400000000000000000001000000F0"
)
var NodeRelatedHeader = pfcp.Header{
Version: 1,
S: 0,
MessageType: pfcp.PFCP_ASSOCIATION_SETUP_REQUEST,
MessageLength: 0,
SequenceNumber: 1,
}
var SessionRelatedHeader = pfcp.Header{
Version: 1,
MP: 1,
S: 1,
MessageType: pfcp.PFCP_SESSION_MODIFICATION_REQUEST,
MessageLength: 0,
SEID: 1,
SequenceNumber: 0,
MessagePriority: 15,
}
func TestPFCPHeader_MarshalBinary(t *testing.T) {
var payload []byte
var expect []byte
// Test PFCP Header for Node Related Messages
payload, _ = NodeRelatedHeader.MarshalBinary()
expect, _ = hex.DecodeString(NodeRelatedHeaderHex)
assert.Equal(t, expect, payload)
// Test PFCP Header for Session Related Messages
payload, _ = SessionRelatedHeader.MarshalBinary()
expect, _ = hex.DecodeString(SessionRelatedHeaderHex)
assert.Equal(t, expect, payload)
}
func TestPFCPHeader_UnmarshalBinary(t *testing.T) {
var tmpHeader pfcp.Header
var payload []byte
// Test PFCP Header for Node Related Messages
payload, _ = hex.DecodeString(NodeRelatedHeaderHex)
_ = tmpHeader.UnmarshalBinary(payload)
assert.Equal(t, NodeRelatedHeader, tmpHeader)
// Test PFCP Header for Session Related Messages
payload, _ = hex.DecodeString(SessionRelatedHeaderHex)
_ = tmpHeader.UnmarshalBinary(payload)
assert.Equal(t, SessionRelatedHeader, tmpHeader)
}