p2p/protocols: fix data race in TestProtocolHook (#19242)

dummyHook's fields were concurrently written by nodes and read by
the test. The simplest solution is to protect all fields with a mutex.

Enable: TestMultiplePeersDropSelf, TestMultiplePeersDropOther as they
seemingly accidentally stayed disabled during a refactor/rewrite
since 1836366ac1.

resolves ethersphere/go-ethereum#1286
This commit is contained in:
Ferenc Szabo
2019-03-08 17:30:16 +01:00
committed by Viktor Trón
parent bb55b0fb53
commit f82185a4a1
3 changed files with 37 additions and 15 deletions

View File

@ -161,7 +161,7 @@ func TestAccountingSimulation(t *testing.T) {
type matrix struct {
n int //number of nodes
m []int64 //array of balances
lock sync.RWMutex
lock sync.Mutex
}
// create a new matrix