Skip to content
Snippets Groups Projects
Commit f88c87e5 authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

static uses our IP type now

parent 6c593157
No related branches found
No related tags found
No related merge requests found
......@@ -5,25 +5,25 @@ import (
"github.com/stretchr/testify/assert"
"github.com/bio-routing/bio-rd/net"
bnet "github.com/bio-routing/bio-rd/net"
)
func TestNewRoute(t *testing.T) {
tests := []struct {
name string
pfx net.Prefix
pfx bnet.Prefix
path *Path
expected *Route
}{
{
name: "BGP Path",
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
path: &Path{
Type: BGPPathType,
BGPPath: &BGPPath{},
},
expected: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
paths: []*Path{
&Path{
Type: BGPPathType,
......@@ -34,9 +34,9 @@ func TestNewRoute(t *testing.T) {
},
{
name: "Empty Path",
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
expected: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
paths: []*Path{},
},
},
......@@ -52,14 +52,14 @@ func TestPrefix(t *testing.T) {
tests := []struct {
name string
route *Route
expected net.Prefix
expected bnet.Prefix
}{
{
name: "Prefix",
route: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
},
expected: net.NewPfx(strAddr("10.0.0.0"), 8),
expected: bnet.NewPfx(strAddr("10.0.0.0"), 8),
},
}
......@@ -78,7 +78,7 @@ func TestAddr(t *testing.T) {
{
name: "Prefix",
route: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
},
expected: 0xa000000,
},
......@@ -99,7 +99,7 @@ func TestPfxlen(t *testing.T) {
{
name: "Prefix",
route: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
},
expected: 8,
},
......@@ -120,7 +120,7 @@ func TestAddPath(t *testing.T) {
}{
{
name: "Regular BGP path",
route: NewRoute(net.NewPfx(strAddr("10.0.0.0"), 8), &Path{
route: NewRoute(bnet.NewPfx(strAddr("10.0.0.0"), 8), &Path{
Type: BGPPathType,
BGPPath: &BGPPath{},
}),
......@@ -129,7 +129,7 @@ func TestAddPath(t *testing.T) {
BGPPath: &BGPPath{},
},
expected: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
paths: []*Path{
{
Type: BGPPathType,
......@@ -144,13 +144,13 @@ func TestAddPath(t *testing.T) {
},
{
name: "Nil path",
route: NewRoute(net.NewPfx(strAddr("10.0.0.0"), 8), &Path{
route: NewRoute(bnet.NewPfx(strAddr("10.0.0.0"), 8), &Path{
Type: BGPPathType,
BGPPath: &BGPPath{},
}),
newPath: nil,
expected: &Route{
pfx: net.NewPfx(strAddr("10.0.0.0"), 8),
pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8),
paths: []*Path{
{
Type: BGPPathType,
......@@ -271,7 +271,7 @@ func TestCopy(t *testing.T) {
{
name: "",
route: &Route{
pfx: net.NewPfx(1000, 8),
pfx: bnet.NewPfx(1000, 8),
ecmpPaths: 2,
paths: []*Path{
{
......@@ -280,7 +280,7 @@ func TestCopy(t *testing.T) {
},
},
expected: &Route{
pfx: net.NewPfx(1000, 8),
pfx: bnet.NewPfx(1000, 8),
ecmpPaths: 2,
paths: []*Path{
{
......@@ -328,7 +328,7 @@ func TestBestPath(t *testing.T) {
{
Type: StaticPathType,
StaticPath: &StaticPath{
NextHop: 32,
NextHop: bnet.IPv4(32),
},
},
},
......@@ -336,7 +336,7 @@ func TestBestPath(t *testing.T) {
expected: &Path{
Type: StaticPathType,
StaticPath: &StaticPath{
NextHop: 32,
NextHop: bnet.IPv4(32),
},
},
},
......@@ -366,13 +366,13 @@ func TestECMPPaths(t *testing.T) {
{
Type: StaticPathType,
StaticPath: &StaticPath{
NextHop: 32,
NextHop: bnet.IPv4(32),
},
},
{
Type: StaticPathType,
StaticPath: &StaticPath{
NextHop: 32,
NextHop: bnet.IPv4(32),
},
},
},
......@@ -381,13 +381,13 @@ func TestECMPPaths(t *testing.T) {
{
Type: StaticPathType,
StaticPath: &StaticPath{
NextHop: 32,
NextHop: bnet.IPv4(32),
},
},
{
Type: StaticPathType,
StaticPath: &StaticPath{
NextHop: 32,
NextHop: bnet.IPv4(32),
},
},
},
......@@ -399,6 +399,6 @@ func TestECMPPaths(t *testing.T) {
}
func strAddr(s string) uint32 {
ret, _ := net.StrToAddr(s)
ret, _ := bnet.StrToAddr(s)
return ret
}
package route
import bnet "github.com/bio-routing/bio-rd/net"
// StaticPath represents a static path of a route
type StaticPath struct {
NextHop uint32
NextHop bnet.IP
}
func (r *Route) staticPathSelection() {
......
......@@ -4,6 +4,7 @@ import (
"testing"
"github.com/bio-routing/bio-rd/net"
bnet "github.com/bio-routing/bio-rd/net"
"github.com/bio-routing/bio-rd/route"
"github.com/stretchr/testify/assert"
......@@ -38,7 +39,7 @@ func TestContainsPfxPath(t *testing.T) {
path: &route.Path{
Type: route.StaticPathType,
StaticPath: &route.StaticPath{
NextHop: 2,
NextHop: bnet.IPv4(2),
},
},
},
......@@ -57,7 +58,7 @@ func TestContainsPfxPath(t *testing.T) {
path: &route.Path{
Type: route.StaticPathType,
StaticPath: &route.StaticPath{
NextHop: 2,
NextHop: bnet.IPv4(2),
},
},
},
......@@ -67,7 +68,7 @@ func TestContainsPfxPath(t *testing.T) {
path: &route.Path{
Type: route.StaticPathType,
StaticPath: &route.StaticPath{
NextHop: 2,
NextHop: bnet.IPv4(2),
},
},
},
......@@ -91,7 +92,7 @@ func TestLocRIB_RemovePathUnknown(t *testing.T) {
&route.Path{
Type: route.StaticPathType,
StaticPath: &route.StaticPath{
NextHop: 2,
NextHop: bnet.IPv4(2),
},
}))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment