summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet/bgp/prefix_sid_test.go
diff options
context:
space:
mode:
authorSerguei Bezverkhi <sbezverk@cisco.com>2020-05-07 04:27:21 -0400
committerSerguei Bezverkhi <sbezverk@cisco.com>2020-05-07 04:27:21 -0400
commit1f01ec26939845d7c19d9284ef84e00b5747d1ad (patch)
tree9bd6510a61492d6b67587478de708862db58a789 /pkg/packet/bgp/prefix_sid_test.go
parent9251c7a7c0ce93c3365090a79146151c4294e393 (diff)
Finish methods and restructure files
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
Diffstat (limited to 'pkg/packet/bgp/prefix_sid_test.go')
-rw-r--r--pkg/packet/bgp/prefix_sid_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/pkg/packet/bgp/prefix_sid_test.go b/pkg/packet/bgp/prefix_sid_test.go
index 6457c8df..82a8732e 100644
--- a/pkg/packet/bgp/prefix_sid_test.go
+++ b/pkg/packet/bgp/prefix_sid_test.go
@@ -5,6 +5,60 @@ import (
"testing"
)
+func TestRoundTripSubSubTLV(t *testing.T) {
+ tests := []struct {
+ name string
+ input []byte
+ }{
+ {
+ name: "SRv6SIDStructureSubSubTLV",
+ input: []byte{0x01, 0x00, 0x06, 0x28, 0x18, 0x10, 0x00, 0x10, 0x40},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ sstlv := &SRv6SIDStructureSubSubTLV{}
+ if err := sstlv.DecodeFromBytes(tt.input); err != nil {
+ t.Fatalf("test failed with error: %+v", err)
+ }
+ recovered, err := sstlv.Serialize()
+ if err != nil {
+ t.Fatalf("test failed with error: %+v", err)
+ }
+ if bytes.Compare(tt.input, recovered) != 0 {
+ t.Fatalf("round trip conversion test failed as expected prefix sid attribute %+v does not match actual: %+v", tt.input, recovered)
+ }
+ })
+ }
+}
+
+func TestRoundTripSubTLV(t *testing.T) {
+ tests := []struct {
+ name string
+ input []byte
+ }{
+ {
+ name: "SRv6InformationSubTLV",
+ input: []byte{0x01, 0x00, 0x1e, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x01, 0x00, 0x06, 0x28, 0x18, 0x10, 0x00, 0x10, 0x40},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ stlv := &SRv6InformationSubTLV{}
+ if err := stlv.DecodeFromBytes(tt.input); err != nil {
+ t.Fatalf("test failed with error: %+v", err)
+ }
+ recovered, err := stlv.Serialize()
+ if err != nil {
+ t.Fatalf("test failed with error: %+v", err)
+ }
+ if bytes.Compare(tt.input, recovered) != 0 {
+ t.Fatalf("round trip conversion test failed as expected prefix sid attribute %+v does not match actual: %+v", tt.input, recovered)
+ }
+ })
+ }
+}
+
func TestRoundTripPrefixSID(t *testing.T) {
tests := []struct {
name string