forked from cerc-io/plugeth
Merge pull request #1969 from karalabe/fix-whisper-tests-datarace
whisper: fix datarace in expiration test
This commit is contained in:
commit
636f67f232
@ -189,13 +189,22 @@ func TestMessageExpiration(t *testing.T) {
|
|||||||
t.Fatalf("failed to inject message: %v", err)
|
t.Fatalf("failed to inject message: %v", err)
|
||||||
}
|
}
|
||||||
// Check that the message is inside the cache
|
// Check that the message is inside the cache
|
||||||
if _, ok := node.messages[envelope.Hash()]; !ok {
|
node.poolMu.RLock()
|
||||||
|
_, found := node.messages[envelope.Hash()]
|
||||||
|
node.poolMu.RUnlock()
|
||||||
|
|
||||||
|
if !found {
|
||||||
t.Fatalf("message not found in cache")
|
t.Fatalf("message not found in cache")
|
||||||
}
|
}
|
||||||
// Wait for expiration and check cache again
|
// Wait for expiration and check cache again
|
||||||
time.Sleep(time.Second) // wait for expiration
|
time.Sleep(time.Second) // wait for expiration
|
||||||
time.Sleep(expirationCycle) // wait for cleanup cycle
|
time.Sleep(expirationCycle) // wait for cleanup cycle
|
||||||
if _, ok := node.messages[envelope.Hash()]; ok {
|
|
||||||
|
node.poolMu.RLock()
|
||||||
|
_, found = node.messages[envelope.Hash()]
|
||||||
|
node.poolMu.RUnlock()
|
||||||
|
|
||||||
|
if found {
|
||||||
t.Fatalf("message not expired from cache")
|
t.Fatalf("message not expired from cache")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user