summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/path_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkg/table/path_test.go')
-rw-r--r--internal/pkg/table/path_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/pkg/table/path_test.go b/internal/pkg/table/path_test.go
index 421502fa..50681a0b 100644
--- a/internal/pkg/table/path_test.go
+++ b/internal/pkg/table/path_test.go
@@ -2,6 +2,7 @@
package table
import (
+ "net"
"testing"
"time"
@@ -363,3 +364,22 @@ func TestReplaceAS(t *testing.T) {
assert.Equal(t, list[2], uint32(10))
assert.Equal(t, list[3], uint32(2))
}
+
+func TestNLRIToIPNet(t *testing.T) {
+ _, n1, _ := net.ParseCIDR("30.30.30.0/24")
+ ipNet := nlriToIPNet(bgp.NewIPAddrPrefix(24, "30.30.30.0"))
+ assert.Equal(t, n1, ipNet)
+
+ _, n2, _ := net.ParseCIDR("2806:106e:19::/48")
+ ipNet = nlriToIPNet(bgp.NewIPv6AddrPrefix(48, "2806:106e:19::"))
+ assert.Equal(t, n2, ipNet)
+
+ labels := bgp.NewMPLSLabelStack(100, 200)
+ _, n3, _ := net.ParseCIDR("30.30.30.0/24")
+ ipNet = nlriToIPNet(bgp.NewLabeledIPAddrPrefix(24, "30.30.30.0", *labels))
+ assert.Equal(t, n3, ipNet)
+
+ _, n4, _ := net.ParseCIDR("2806:106e:19::/48")
+ ipNet = nlriToIPNet(bgp.NewLabeledIPv6AddrPrefix(48, "2806:106e:19::", *labels))
+ assert.Equal(t, n4, ipNet)
+}