summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet/bgp/prefix_sid_sstlv_test.go
diff options
context:
space:
mode:
authorSerguei Bezverkhi <sbezverk@cisco.com>2020-05-06 15:44:17 -0400
committerSerguei Bezverkhi <sbezverk@cisco.com>2020-05-06 15:44:17 -0400
commit9251c7a7c0ce93c3365090a79146151c4294e393 (patch)
tree9128b2456f6dd2002d35de1bf6b7cff9df1fa04e /pkg/packet/bgp/prefix_sid_sstlv_test.go
parentcd4b9c5b0abfbe73fc7ffc63725a758b7242d759 (diff)
code Decode and Serialize for Prefix SID types and add unit tests
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
Diffstat (limited to 'pkg/packet/bgp/prefix_sid_sstlv_test.go')
-rw-r--r--pkg/packet/bgp/prefix_sid_sstlv_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/pkg/packet/bgp/prefix_sid_sstlv_test.go b/pkg/packet/bgp/prefix_sid_sstlv_test.go
new file mode 100644
index 00000000..478ee431
--- /dev/null
+++ b/pkg/packet/bgp/prefix_sid_sstlv_test.go
@@ -0,0 +1,33 @@
+package bgp
+
+import (
+ "bytes"
+ "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)
+ }
+ })
+ }
+}