From 0aead1d2f985ee6441c642fd0287d7d0ba408093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gianguido=20Sor=C3=A0?= Date: Mon, 21 Oct 2024 12:25:20 +0200 Subject: [PATCH] testutil/integration: fix nightly test behavior (#3343) Instead of passing errors around with channels, which in this specific test might alter timings, just panic when error is not of "context canceled" kind, during the induced restart phase. Not ideal, but simple and effective. category: bug ticket: none --- testutil/integration/nightly_dkg_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/testutil/integration/nightly_dkg_test.go b/testutil/integration/nightly_dkg_test.go index ab0ad6b10..3ac97226a 100644 --- a/testutil/integration/nightly_dkg_test.go +++ b/testutil/integration/nightly_dkg_test.go @@ -9,6 +9,7 @@ import ( "math/rand" "os" "path" + "strings" "testing" "time" @@ -25,8 +26,6 @@ import ( "github.com/obolnetwork/charon/p2p" ) -const ctxCanceledErr = "context canceled" - var ( nightly = flag.Bool("nightly", false, "Enable nightly integration tests") quickRun = flag.Bool("quick-run", false, "Enable quick long-wait DKG that finishes in a minute") @@ -162,17 +161,16 @@ func mimicDKGNode(parentCtx context.Context, t *testing.T, dkgConf dkg.Config, w log.Debug(ctx, "Starting DKG node", z.Int("node", nodeIdx), z.Bool("first_time", firstTime)) - errCh := make(chan error, 1) go func(ctx context.Context) { // Ensure DKGs don't save their artifacts in the same node directory since the current DKG would error // as it would find an existing private key lock file previously created by earlier DKGs. conf := dkgConf conf.DataDir = t.TempDir() err := dkg.Run(ctx, conf) - errCh <- err + if !strings.Contains(err.Error(), context.Canceled.Error()) { + panic("error is not of context canceled kind") + } }(ctx) - err := <-errCh - require.ErrorContains(t, err, ctxCanceledErr) return cancelFunc }