Skip to content

Commit 3a4a600

Browse files
authored
Merge pull request #1688 from aboch/ptst
Fix panic in networkdb test code
2 parents b6cb1ee + 2b0ac12 commit 3a4a600

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

networkdb/networkdb_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ func closeNetworkDBInstances(dbs []*NetworkDB) {
5555

5656
func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool) {
5757
for i := 0; i < 80; i++ {
58+
db.RLock()
5859
_, ok := db.nodes[node]
60+
db.RUnlock()
5961
if present && ok {
6062
return
6163
}
@@ -72,7 +74,10 @@ func (db *NetworkDB) verifyNodeExistence(t *testing.T, node string, present bool
7274

7375
func (db *NetworkDB) verifyNetworkExistence(t *testing.T, node string, id string, present bool) {
7476
for i := 0; i < 80; i++ {
75-
if nn, nnok := db.networks[node]; nnok {
77+
db.RLock()
78+
nn, nnok := db.networks[node]
79+
db.RUnlock()
80+
if nnok {
7681
n, ok := nn[id]
7782
if present && ok {
7883
return

0 commit comments

Comments
 (0)