Skip to content

Commit

Permalink
testutil/integration: fix nightly test behavior (#3343)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gsora authored Oct 21, 2024
1 parent 774902f commit 0aead1d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions testutil/integration/nightly_dkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"math/rand"
"os"
"path"
"strings"
"testing"
"time"

Expand All @@ -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")
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 0aead1d

Please sign in to comment.