mirror of
https://github.com/tendermint/tendermint.git
synced 2025-12-23 14:25:19 +00:00
p2p/pex: fix DATA RACE
in TestPEXReactorDialsPeerUpToMaxAttemptsInSeedMode Closes #4668 ______ For contributor use: - [x] Wrote tests - [ ] ~~Updated CHANGELOG_PENDING.md~~ - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] ~~Updated relevant documentation (`docs/`) and code comments~~ - [x] Re-reviewed `Files changed` in the Github PR explorer
This commit is contained in:
@@ -378,9 +378,7 @@ func TestPEXReactorDialsPeerUpToMaxAttemptsInSeedMode(t *testing.T) {
|
||||
|
||||
sw := createSwitchAndAddReactors(pexR)
|
||||
sw.SetAddrBook(book)
|
||||
err = sw.Start()
|
||||
require.NoError(t, err)
|
||||
defer sw.Stop()
|
||||
// No need to start sw since crawlPeers is called manually here.
|
||||
|
||||
peer := mock.NewPeer(nil)
|
||||
addr := peer.SocketAddr()
|
||||
@@ -389,9 +387,11 @@ func TestPEXReactorDialsPeerUpToMaxAttemptsInSeedMode(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.True(t, book.HasAddress(addr))
|
||||
|
||||
// imitate maxAttemptsToDial reached
|
||||
pexR.attemptsToDial.Store(addr.DialString(), _attemptsToDial{maxAttemptsToDial + 1, time.Now()})
|
||||
pexR.crawlPeers([]*p2p.NetAddress{addr})
|
||||
|
||||
assert.False(t, book.HasAddress(addr))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user