diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-22 09:22:31 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-22 09:22:31 -0400 |
commit | 36b61f5f38bd2aae78353fa112c0787f0a89a31f (patch) | |
tree | 5ff772aeacbe6f3caf54cd8685a9ee8b19c4d0cb /pkg/ipstack/ipstack_test.go | |
parent | a935739d332ccb82174ddb925dcf5e473dfae41f (diff) |
forwarding works as expected among multiple subnets, but checksum fails. will focus more on RIP timeouts next.
Diffstat (limited to 'pkg/ipstack/ipstack_test.go')
-rw-r--r-- | pkg/ipstack/ipstack_test.go | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/pkg/ipstack/ipstack_test.go b/pkg/ipstack/ipstack_test.go index 5cef903..e782f67 100644 --- a/pkg/ipstack/ipstack_test.go +++ b/pkg/ipstack/ipstack_test.go @@ -250,31 +250,20 @@ import ( //} func TestIntersect(t *testing.T) { - net1 := netip.MustParsePrefix("1.1.1.1/24") + net1 := netip.MustParsePrefix("10.0.0.0/24") net2 := netip.MustParsePrefix("1.1.1.2/24") net3 := netip.MustParsePrefix("1.0.0.1/24") net4 := netip.MustParsePrefix("0.0.0.0/0") // default route - net5 := netip.MustParsePrefix("1.1.1.1/32") + net5 := netip.MustParsePrefix("10.2.0.3/32") - res00 := intersect(net1, net5) - if !res00 { - t.Error("net1 and net2 should intersect") + res00 := intersect(net5, net1) + if res00 { + t.Error("net5 -> net1 should not intersect") t.Fail() } - res01 := intersect(net5, net1) - if res01 { - t.Error("net1 and net2 should not intersect") - t.Fail() - } - - res1 := intersect(net1, net2) - if !res1 { - t.Error("net1 and net2 should intersect") - t.Fail() - } - res0 := intersect(net2, net1) - if !res0 { - t.Error("net1 and net2 should intersect") + res01 := intersect(net5, net4) + if !res01 { + t.Error("net5 -> net4 should intersect") t.Fail() } @@ -306,3 +295,7 @@ func TestIntersect(t *testing.T) { fmt.Println("TestIntersect successful") } + +func intersect(n1, n2 netip.Prefix) bool { + return n1.Overlaps(n2) +} |