mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-01-15 02:40:07 +08:00
adjust ttl tests as badger doesn't support sub-second ttl.
This commit is contained in:
parent
23be462e82
commit
7c5cf50d9b
@ -154,25 +154,27 @@ func testUpdateTTLs(m pstore.AddrBook) func(t *testing.T) {
|
||||
testHas(t, addrs2, m.Addrs(ids[1]))
|
||||
|
||||
// Will only affect addrs1[0].
|
||||
m.UpdateAddrs(ids[0], time.Hour, 100*time.Microsecond)
|
||||
// Badger does not support subsecond TTLs.
|
||||
// https://github.com/dgraph-io/badger/issues/339
|
||||
m.UpdateAddrs(ids[0], time.Hour, 1*time.Second)
|
||||
|
||||
// No immediate effect.
|
||||
testHas(t, addrs1, m.Addrs(ids[0]))
|
||||
testHas(t, addrs2, m.Addrs(ids[1]))
|
||||
|
||||
// After a wait, addrs[0] is gone.
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(1500 * time.Millisecond)
|
||||
testHas(t, addrs1[1:2], m.Addrs(ids[0]))
|
||||
testHas(t, addrs2, m.Addrs(ids[1]))
|
||||
|
||||
// Will only affect addrs2[0].
|
||||
m.UpdateAddrs(ids[1], time.Hour, 100*time.Microsecond)
|
||||
m.UpdateAddrs(ids[1], time.Hour, 1*time.Second)
|
||||
|
||||
// No immediate effect.
|
||||
testHas(t, addrs1[1:2], m.Addrs(ids[0]))
|
||||
testHas(t, addrs2, m.Addrs(ids[1]))
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(1500 * time.Millisecond)
|
||||
|
||||
// First addrs is gone in both.
|
||||
testHas(t, addrs1[1:], m.Addrs(ids[0]))
|
||||
|
Loading…
Reference in New Issue
Block a user