From dbc3ee3e9dc50e01dab9ae789a44f90502542335 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Fri, 2 Jun 2017 18:02:04 +0200 Subject: [PATCH] Trie random test Test trie against naive implementation of prefix routing. --- src/trie_rand_test.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/trie_rand_test.go b/src/trie_rand_test.go index f8b860c..840d269 100644 --- a/src/trie_rand_test.go +++ b/src/trie_rand_test.go @@ -12,7 +12,13 @@ const ( NumberOfTests = 10000 ) -type SlowRouter []*Trie +type SlowNode struct { + peer *Peer + cidr uint + bits []byte +} + +type SlowRouter []*SlowNode func (r SlowRouter) Len() int { return len(r) @@ -34,7 +40,7 @@ func (r SlowRouter) Insert(addr []byte, cidr uint, peer *Peer) SlowRouter { return r } } - r = append(r, &Trie{ + r = append(r, &SlowNode{ cidr: cidr, bits: addr, peer: peer, @@ -81,7 +87,7 @@ func TestTrieRandomIPv4(t *testing.T) { peer1 := slow.Lookup(addr[:]) peer2 := trie.Lookup(addr[:]) if peer1 != peer2 { - t.Error("Trie did not match niave implementation, for:", addr) + t.Error("Trie did not match naive implementation, for:", addr) } } } @@ -114,7 +120,7 @@ func TestTrieRandomIPv6(t *testing.T) { peer1 := slow.Lookup(addr[:]) peer2 := trie.Lookup(addr[:]) if peer1 != peer2 { - t.Error("Trie did not match niave implementation, for:", addr) + t.Error("Trie did not match naive implementation, for:", addr) } } }