mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm/network/stream: fix TestGetSubscriptionsRPC data race
https://github.com/ethersphere/go-ethereum/issues/1198#issuecomment-461768477
This commit is contained in:
parent
edfee9cacb
commit
91f87355a2
1 changed files with 7 additions and 2 deletions
|
|
@ -1293,7 +1293,9 @@ func TestGetSubscriptionsRPC(t *testing.T) {
|
|||
t.Fatal("Context timed out")
|
||||
}
|
||||
|
||||
lock.RLock()
|
||||
log.Debug("Expected message count: ", "expectedMsgCount", expectedMsgCount)
|
||||
lock.RUnlock()
|
||||
//now iterate again, this time we call each node via RPC to get its subscriptions
|
||||
realCount := 0
|
||||
for _, node := range nodes {
|
||||
|
|
@ -1324,8 +1326,11 @@ func TestGetSubscriptionsRPC(t *testing.T) {
|
|||
}
|
||||
}
|
||||
// every node is mutually subscribed to each other, so the actual count is half of it
|
||||
if realCount/2 != expectedMsgCount {
|
||||
return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount/2, expectedMsgCount)
|
||||
lock.RLock()
|
||||
emc := expectedMsgCount
|
||||
lock.RUnlock()
|
||||
if realCount/2 != emc {
|
||||
return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount/2, emc)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue