diff --git a/rt/route.go b/rt/route.go index 42dd416244a2b46f7080fbc10ea7852f3b5f7760..f902748611fdad60b03a31e1194c35930c27587c 100644 --- a/rt/route.go +++ b/rt/route.go @@ -116,7 +116,7 @@ func getBestProtocol(paths []*Path) uint8 { continue } - if p.Type > best { + if p.Type < best { best = p.Type } } diff --git a/rt/route_test.go b/rt/route_test.go index d4633694903eae24d79a35a0803c4b07edfa5073..ecd88a04168a225a513f07f6d2fb2b96b05d2f22 100644 --- a/rt/route_test.go +++ b/rt/route_test.go @@ -367,3 +367,29 @@ func TestAddPaths(t *testing.T) { assert.Equal(t, test.expected, test.route) } } + +func TestGetBestProtocol(t *testing.T) { + tests := []struct { + name string + input []*Path + expected uint8 + }{ + { + name: "Foo", + input: []*Path{ + { + Type: BGPPathType, + }, + { + Type: StaticPathType, + }, + }, + expected: StaticPathType, + }, + } + + for _, test := range tests { + res := getBestProtocol(test.input) + assert.Equal(t, test.expected, res) + } +}