Skip to content

Commit 3eab461

Browse files
committed
p2p/discover: add test for lookup returning immediately
Signed-off-by: Csaba Kiraly <[email protected]>
1 parent 72d3e88 commit 3eab461

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

p2p/discover/v4_lookup_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"slices"
2424
"sync"
2525
"testing"
26+
"time"
2627

2728
"github.com/ethereum/go-ethereum/crypto"
2829
"github.com/ethereum/go-ethereum/p2p/discover/v4wire"
@@ -34,11 +35,15 @@ func TestUDPv4_Lookup(t *testing.T) {
3435
t.Parallel()
3536
test := newUDPTest(t)
3637

37-
// Lookup on empty table returns no nodes.
38+
// Lookup on empty table returns immediately with no nodes.
3839
targetKey, _ := v4wire.DecodePubkey(crypto.S256(), lookupTestnet.target)
40+
start := time.Now()
3941
if results := test.udp.LookupPubkey(targetKey); len(results) > 0 {
4042
t.Fatalf("lookup on empty table returned %d results: %#v", len(results), results)
4143
}
44+
if time.Since(start) > 100*time.Millisecond {
45+
t.Fatalf("lookup on empty table took too long: %s", time.Since(start))
46+
}
4247

4348
// Seed table with initial node.
4449
fillTable(test.table, []*enode.Node{lookupTestnet.node(256, 0)}, true)

0 commit comments

Comments
 (0)