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

fixed more tests

parent 6a4e9435
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@ import (
"fmt"
"testing"
"github.com/bio-routing/bio-rd/net"
"github.com/stretchr/testify/assert"
"github.com/taktv6/tflow2/convert"
)
......@@ -205,10 +206,10 @@ func TestDecode(t *testing.T) {
Body: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -405,10 +406,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -431,10 +432,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -473,10 +474,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -577,10 +578,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -655,10 +656,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -749,10 +750,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -856,10 +857,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -974,10 +975,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -1108,10 +1109,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
expected: &BGPUpdate{
WithdrawnRoutesLen: 5,
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -1200,7 +1201,7 @@ func TestDecodeUpdateMsg(t *testing.T) {
},
NLRI: &NLRI{
Pfxlen: 8,
IP: [4]byte{11, 0, 0, 0},
IP: strAddr("1.0.0.0"),
},
},
},
......@@ -1534,3 +1535,8 @@ func TestValidateOpenMessage(t *testing.T) {
}
}
}
func strAddr(s string) uint32 {
ret, _ := net.StrToAddr(s)
return ret
}
......@@ -23,13 +23,13 @@ func TestDecodeNLRIs(t *testing.T) {
},
wantFail: false,
expected: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 24,
Next: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{172, 16, 0, 0},
IP: strAddr("172.16.0.0"),
Pfxlen: 17,
},
},
......@@ -76,7 +76,7 @@ func TestDecodeNLRI(t *testing.T) {
},
wantFail: false,
expected: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 24,
},
},
......@@ -87,7 +87,7 @@ func TestDecodeNLRI(t *testing.T) {
},
wantFail: false,
expected: &NLRI{
IP: [4]byte{192, 168, 0, 128},
IP: strAddr("192.168.0.128"),
Pfxlen: 25,
},
},
......@@ -178,7 +178,7 @@ func TestNLRISerialize(t *testing.T) {
{
name: "Test #1",
nlri: &NLRI{
IP: [4]byte{1, 2, 3, 0},
IP: strAddr("1.2.3.0"),
Pfxlen: 25,
},
expected: []byte{25, 1, 2, 3, 0},
......@@ -186,7 +186,7 @@ func TestNLRISerialize(t *testing.T) {
{
name: "Test #2",
nlri: &NLRI{
IP: [4]byte{1, 2, 3, 0},
IP: strAddr("1.2.3.0"),
Pfxlen: 24,
},
expected: []byte{24, 1, 2, 3},
......@@ -194,7 +194,7 @@ func TestNLRISerialize(t *testing.T) {
{
name: "Test #3",
nlri: &NLRI{
IP: [4]byte{100, 200, 128, 0},
IP: strAddr("100.200.128.0"),
Pfxlen: 17,
},
expected: []byte{17, 100, 200, 128},
......
......
......@@ -725,7 +725,7 @@ func TestASPathString(t *testing.T) {
{
name: "Test #1",
pa: &PathAttribute{
Value: &ASPath{
Value: ASPath{
{
Type: ASSequence,
ASNs: []uint32{10, 20, 30},
......@@ -737,7 +737,7 @@ func TestASPathString(t *testing.T) {
{
name: "Test #2",
pa: &PathAttribute{
Value: &ASPath{
Value: ASPath{
{
Type: ASSequence,
ASNs: []uint32{10, 20, 30},
......@@ -1106,7 +1106,7 @@ func TestSerialize(t *testing.T) {
name: "Withdraw only",
msg: &BGPUpdate{
WithdrawnRoutes: &NLRI{
IP: [4]byte{100, 110, 120, 0},
IP: strAddr("100.110.120.0"),
Pfxlen: 24,
},
},
......@@ -1123,7 +1123,7 @@ func TestSerialize(t *testing.T) {
name: "NLRI only",
msg: &BGPUpdate{
NLRI: &NLRI{
IP: [4]byte{100, 110, 128, 0},
IP: strAddr("100.110.128.0"),
Pfxlen: 17,
},
},
......@@ -1162,10 +1162,10 @@ func TestSerialize(t *testing.T) {
name: "Full test",
msg: &BGPUpdate{
WithdrawnRoutes: &NLRI{
IP: [4]byte{10, 0, 0, 0},
IP: strAddr("10.0.0.0"),
Pfxlen: 8,
Next: &NLRI{
IP: [4]byte{192, 168, 0, 0},
IP: strAddr("192.168.0.0"),
Pfxlen: 16,
},
},
......@@ -1206,10 +1206,10 @@ func TestSerialize(t *testing.T) {
},
},
NLRI: &NLRI{
IP: [4]byte{8, 8, 8, 0},
IP: strAddr("8.8.8.0"),
Pfxlen: 24,
Next: &NLRI{
IP: [4]byte{185, 65, 240, 0},
IP: strAddr("185.65.240.0"),
Pfxlen: 22,
},
},
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment