mirror of https://github.com/status-im/op-geth.git
p2p/protocols: fix race condition in TestAccountingSimulation (#19228)
p2p/protocols: Fix race condition in TestAccountingSimulation
This commit is contained in:
parent
ce3ea8c9b1
commit
f2d6310354
|
@ -161,6 +161,7 @@ func TestAccountingSimulation(t *testing.T) {
|
|||
type matrix struct {
|
||||
n int //number of nodes
|
||||
m []int64 //array of balances
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
// create a new matrix
|
||||
|
@ -177,7 +178,9 @@ func (m *matrix) add(i, j int, v int64) error {
|
|||
// i * number of nodes + remote node
|
||||
mi := i*m.n + j
|
||||
// register that balance
|
||||
m.lock.Lock()
|
||||
m.m[mi] += v
|
||||
m.lock.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue