adjust ttl tests as badger doesn't support sub-second ttl.

This commit is contained in:
Raúl Kripalani 2018-09-13 16:09:32 +01:00
parent 23be462e82
commit 7c5cf50d9b

View File

@ -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]))