Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

swap: fix a rare panic in TestMultiChequeSimulation #1944

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions swap/simulations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func TestMultiChequeSimulation(t *testing.T) {
// get the testService for the creditor
creditorSvc := sim.Service("swap", creditor).(*testService)

var debLen, credLen int
var debLen, credLen, debSwapLen, credSwapLen int
timeout := time.After(10 * time.Second)
for {
// let's always be nice and allow a time out to be catched
Expand All @@ -430,14 +430,16 @@ func TestMultiChequeSimulation(t *testing.T) {
}
// the node has all other peers in its peer list
debitorSvc.swap.peersLock.Lock()
debLen = len(debitorSvc.swap.peers)
debSwapLen = len(debitorSvc.swap.peers)
debLen = len(debitorSvc.peers)
debitorSvc.swap.peersLock.Unlock()

creditorSvc.swap.peersLock.Lock()
credLen = len(creditorSvc.swap.peers)
credSwapLen = len(creditorSvc.swap.peers)
credLen = len(creditorSvc.peers)
creditorSvc.swap.peersLock.Unlock()

if debLen == 1 && credLen == 1 {
if debLen == 1 && credLen == 1 && debSwapLen == 1 && credSwapLen == 1 {
break
}
// don't overheat the CPU...
Expand Down