diff options
author | subtly <subtly@users.noreply.github.com> | 2015-05-14 02:03:17 +0800 |
---|---|---|
committer | subtly <subtly@users.noreply.github.com> | 2015-05-14 02:03:17 +0800 |
commit | a32693770c607a17eab6d8d068e4c9b1cddbbd54 (patch) | |
tree | 62fe9bb0c7bda86238bc2d0260b958d6a1234ce9 /p2p/discover/udp_test.go | |
parent | 7473c93668e42cfc13c89ab660b6ea262ebf9bf4 (diff) | |
download | dexon-a32693770c607a17eab6d8d068e4c9b1cddbbd54.tar.gz dexon-a32693770c607a17eab6d8d068e4c9b1cddbbd54.tar.zst dexon-a32693770c607a17eab6d8d068e4c9b1cddbbd54.zip |
Manual send of multiple neighbours packets. Test receiving multiple neighbours packets.
Diffstat (limited to 'p2p/discover/udp_test.go')
-rw-r--r-- | p2p/discover/udp_test.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/p2p/discover/udp_test.go b/p2p/discover/udp_test.go index f175835a8..ae9e41251 100644 --- a/p2p/discover/udp_test.go +++ b/p2p/discover/udp_test.go @@ -163,9 +163,19 @@ func TestUDP_findnode(t *testing.T) { )) // check that closest neighbors are returned. test.packetIn(nil, findnodePacket, &findnode{Target: testTarget, Expiration: futureExp}) + expected := test.table.closest(targetHash, bucketSize) test.waitPacketOut(func(p *neighbors) { - expected := test.table.closest(targetHash, bucketSize) - if len(p.Nodes) != bucketSize { + if len(p.Nodes) != 13 { + t.Errorf("wrong number of results: got %d, want %d", len(p.Nodes), bucketSize) + } + for i := range p.Nodes { + if p.Nodes[i].ID != expected.entries[i].ID { + t.Errorf("result mismatch at %d:\n got: %v\n want: %v", i, p.Nodes[i], expected.entries[i]) + } + } + }) + test.waitPacketOut(func(p *neighbors) { + if len(p.Nodes) != 3 { t.Errorf("wrong number of results: got %d, want %d", len(p.Nodes), bucketSize) } for i := range p.Nodes { |