mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
p2p/discover: add test for lookup returning immediately
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
72d3e881b3
commit
3eab4616a6
1 changed files with 6 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ import (
|
|||
"slices"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/p2p/discover/v4wire"
|
||||
|
|
@ -34,11 +35,15 @@ func TestUDPv4_Lookup(t *testing.T) {
|
|||
t.Parallel()
|
||||
test := newUDPTest(t)
|
||||
|
||||
// Lookup on empty table returns no nodes.
|
||||
// Lookup on empty table returns immediately with no nodes.
|
||||
targetKey, _ := v4wire.DecodePubkey(crypto.S256(), lookupTestnet.target)
|
||||
start := time.Now()
|
||||
if results := test.udp.LookupPubkey(targetKey); len(results) > 0 {
|
||||
t.Fatalf("lookup on empty table returned %d results: %#v", len(results), results)
|
||||
}
|
||||
if time.Since(start) > 100*time.Millisecond {
|
||||
t.Fatalf("lookup on empty table took too long: %s", time.Since(start))
|
||||
}
|
||||
|
||||
// Seed table with initial node.
|
||||
fillTable(test.table, []*enode.Node{lookupTestnet.node(256, 0)}, true)
|
||||
|
|
|
|||
Loading…
Reference in a new issue