Skip to content

Commit

Permalink
fix: race in paych manager test
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc committed Aug 5, 2020
1 parent c6c118e commit b3bdd2b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions paychmgr/paychget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,24 @@ func (pchapi *mockPaychAPI) receiveMsgResponse(mcid cid.Cid, receipt types.Messa
if call, ok := pchapi.waitingCalls[mcid]; ok {
delete(pchapi.waitingCalls, mcid)
call.response <- receipt
return
}

pchapi.responses[mcid] = receipt
}

// Send success response for any waiting calls
func (pchapi *mockPaychAPI) close() {
for mcid := range pchapi.waitingCalls {
pchapi.receiveMsgResponse(mcid, types.MessageReceipt{
ExitCode: 0,
Return: []byte{},
})
pchapi.lk.Lock()
defer pchapi.lk.Unlock()

success := types.MessageReceipt{
ExitCode: 0,
Return: []byte{},
}
for mcid, call := range pchapi.waitingCalls {
delete(pchapi.waitingCalls, mcid)
call.response <- success
}
}

Expand Down

0 comments on commit b3bdd2b

Please sign in to comment.