Skip to content

Commit e596d69

Browse files
authored
testutil/integration: fix nightly test (#4451)
Use errors.Is instead of string comparison to properly detect context.Canceled through wrapped error chains. Also handle nil error case to prevent panic on err.Error() call.
1 parent 20cfcad commit e596d69

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

testutil/integration/nightly_dkg_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"math/rand"
1010
"os"
1111
"path"
12-
"strings"
1312
"testing"
1413
"time"
1514

@@ -173,8 +172,8 @@ func mimicDKGNode(parentCtx context.Context, t *testing.T, dkgConf dkg.Config, w
173172
conf.DataDir = t.TempDir()
174173

175174
err := dkg.Run(ctx, conf)
176-
if !strings.Contains(err.Error(), context.Canceled.Error()) {
177-
panic("error is not of context canceled kind")
175+
if err != nil && !errors.Is(err, context.Canceled) {
176+
panic(fmt.Sprintf("error is not of context canceled kind: %v", err))
178177
}
179178
}(ctx)
180179

0 commit comments

Comments
 (0)