Test a little bit better
@@ -125,35 +125,25 @@ func TestNeighborhood_Broadcast4(t *testing.T) {
n.AddIncomingPeer(rnd, con)
n.Broadcast([]byte("LOL"))
- tm := time.NewTimer(time.Millisecond * 5)
+ tm := time.NewTimer(time.Second)
loop:
for {
select {
case <-tm.C:
- n.peersMutex.Lock()
- for _, p := range n.peers {
- i := p.conn.(*net.ConnectionMock).SendCount()
- if assert.True(t, i > 0) {
- n.peersMutex.Unlock()
- break loop
- }
+ t.Error()
+ default:
}
- n.peersMutex.Unlock()
- n.inpeersMutex.Lock()
+ n.inpeersMutex.RLock()
for _, p := range n.inpeers {
i := p.conn.(*net.ConnectionMock).SendCount()
- if assert.True(t, i > 0) {
- n.inpeersMutex.Unlock()
+ if i > 0 {
break loop
}
}
- n.inpeersMutex.Lock()
- break loop
- default:
+ n.inpeersMutex.RUnlock()
}
}
-}
func Test_Neihborhood_getMorePeers(t *testing.T) {
// test normal flow
