aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-11-05 20:03:36 +0800
committerFelix Lange <fjl@twurst.com>2015-11-05 20:03:36 +0800
commit636f67f232ed44aebafac93e9d3b4f010a598815 (patch)
tree3ba4f3db7c77fc3857a189d964c58cd003469918
parenteb11c0e597b9a2c3256bc29f531d3976b0a1c729 (diff)
parent60e0abb5957560ba760ba4ed2669244f2528bd09 (diff)
downloaddexon-636f67f232ed44aebafac93e9d3b4f010a598815.tar.gz
dexon-636f67f232ed44aebafac93e9d3b4f010a598815.tar.zst
dexon-636f67f232ed44aebafac93e9d3b4f010a598815.zip
Merge pull request #1969 from karalabe/fix-whisper-tests-datarace
whisper: fix datarace in expiration test
-rw-r--r--whisper/whisper_test.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go
index b5a919984..1a9a8667a 100644
--- a/whisper/whisper_test.go
+++ b/whisper/whisper_test.go
@@ -189,13 +189,22 @@ func TestMessageExpiration(t *testing.T) {
t.Fatalf("failed to inject message: %v", err)
}
// 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")
}
// Wait for expiration and check cache again
time.Sleep(time.Second) // wait for expiration
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")
}
}