Skip to content

Commit 785c533

Browse files
committed
Fixes wrong stop of nodes in the integration test
1 parent 146dff0 commit 785c533

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

integration/integration_test.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ func getIntegrationTest(numNodes, numVotes int) func(*testing.T) {
176176
require.True(t, ok)
177177
}
178178

179-
closeNodes(t, nodes)
179+
fmt.Println("closing nodes")
180+
181+
err = closeNodes(nodes)
182+
require.NoError(t, err)
183+
184+
fmt.Println("test done")
180185
}
181186
}
182187

@@ -547,7 +552,7 @@ func decryptBallots(m txManager, actor dkg.Actor, election types.Election) error
547552
return nil
548553
}
549554

550-
func closeNodes(t *testing.T, nodes []dVotingCosiDela) {
555+
func closeNodes(nodes []dVotingCosiDela) error {
551556
wait := sync.WaitGroup{}
552557
wait.Add(len(nodes))
553558

@@ -558,20 +563,19 @@ func closeNodes(t *testing.T, nodes []dVotingCosiDela) {
558563
}(n.(dVotingNode))
559564
}
560565

561-
t.Log("stopping nodes...")
562-
563566
done := make(chan struct{})
564567

565568
go func() {
566-
select {
567-
case <-done:
568-
case <-time.After(time.Second * 30):
569-
t.Error("timeout while closing nodes")
570-
}
569+
wait.Wait()
570+
close(done)
571571
}()
572572

573-
wait.Wait()
574-
close(done)
573+
select {
574+
case <-done:
575+
return nil
576+
case <-time.After(time.Second * 30):
577+
return xerrors.New("failed to close: timeout")
578+
}
575579
}
576580

577581
func encodeID(ID string) types.ID {

0 commit comments

Comments
 (0)