p2p/discover: fix test

This commit is contained in:
Felix Lange 2024-05-28 19:05:06 +02:00
parent 6cab7ddfe0
commit 8570ef0f46
2 changed files with 4 additions and 2 deletions

View file

@ -28,6 +28,8 @@ import (
const never = mclock.AbsTime(math.MaxInt64) const never = mclock.AbsTime(math.MaxInt64)
const slowRevalidationFactor = 3
// tableRevalidation implements the node revalidation process. // tableRevalidation implements the node revalidation process.
// It tracks all nodes contained in Table, and schedules sending PING to them. // It tracks all nodes contained in Table, and schedules sending PING to them.
type tableRevalidation struct { type tableRevalidation struct {
@ -48,7 +50,7 @@ func (tr *tableRevalidation) init(cfg *Config) {
tr.fast.interval = cfg.PingInterval tr.fast.interval = cfg.PingInterval
tr.fast.name = "fast" tr.fast.name = "fast"
tr.slow.nextTime = never tr.slow.nextTime = never
tr.slow.interval = cfg.PingInterval * 3 tr.slow.interval = cfg.PingInterval * slowRevalidationFactor
tr.slow.name = "slow" tr.slow.name = "slow"
} }

View file

@ -131,7 +131,7 @@ func waitForRevalidationPing(t *testing.T, transport *pingRecorder, tab *Table,
simclock := tab.cfg.Clock.(*mclock.Simulated) simclock := tab.cfg.Clock.(*mclock.Simulated)
maxAttempts := tab.len() * 8 maxAttempts := tab.len() * 8
for i := 0; i < maxAttempts; i++ { for i := 0; i < maxAttempts; i++ {
simclock.Run(tab.cfg.PingInterval) simclock.Run(tab.cfg.PingInterval * slowRevalidationFactor)
p := transport.waitPing(2 * time.Second) p := transport.waitPing(2 * time.Second)
if p == nil { if p == nil {
t.Fatal("Table did not send revalidation ping") t.Fatal("Table did not send revalidation ping")