Skip to content

Commit

Permalink
Add more info to failing systests (#6523)
Browse files Browse the repository at this point in the history
## Motivation

Instead of just printing `unknown error: EOF` add a bit more info as to why watching transaction results sometimes fails.
  • Loading branch information
fasmat committed Dec 5, 2024
1 parent 22d5796 commit 138e9bd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
15 changes: 15 additions & 0 deletions systest/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ BACKOFF:
state, err := states.Recv()
s, ok := status.FromError(err)
if !ok {
if ctx.Err() != nil {
return ctx.Err()
}
return fmt.Errorf("unknown error: %w", err)
}
switch s.Code() {
Expand Down Expand Up @@ -190,6 +193,9 @@ BACKOFF:
layer, err := layers.Recv()
s, ok := status.FromError(err)
if !ok {
if ctx.Err() != nil {
return ctx.Err()
}
return fmt.Errorf("unknown error: %w", err)
}
switch s.Code() {
Expand Down Expand Up @@ -235,6 +241,9 @@ BACKOFF:
proof, err := proofs.Recv()
s, ok := status.FromError(err)
if !ok {
if ctx.Err() != nil {
return ctx.Err()
}
return fmt.Errorf("unknown error: %w", err)
}
switch s.Code() {
Expand Down Expand Up @@ -337,6 +346,9 @@ BACKOFF:
rst, err := rsts.Recv()
s, ok := status.FromError(err)
if !ok {
if ctx.Err() != nil {
return ctx.Err()
}
return fmt.Errorf("unknown error: %w", err)
}
switch s.Code() {
Expand Down Expand Up @@ -384,6 +396,9 @@ func watchProposals(
proposal, err := proposals.Recv()
s, ok := status.FromError(err)
if !ok {
if ctx.Err() != nil {
return ctx.Err()
}
return fmt.Errorf("unknown error: %w", err)
}
switch s.Code() {
Expand Down
23 changes: 17 additions & 6 deletions systest/tests/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package tests
import (
"context"
"encoding/hex"
"fmt"
"testing"
"time"

pb "github.com/spacemeshos/api/release/go/spacemesh/v1"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

"github.com/spacemeshos/go-spacemesh/common/types"
Expand Down Expand Up @@ -60,19 +62,28 @@ func testTransactions(
for i := range cl.Total() {
client := cl.Client(i)
eg.Go(func() error {
return watchTransactionResults(ctx, client, tctx.Log.Desugar(),
err := watchTransactionResults(ctx, client, tctx.Log.Desugar(),
func(rst *pb.TransactionResult) (bool, error) {
txs[i] = append(txs[i], rst.Tx)
count := len(txs[i])
tctx.Log.Debugw("received transaction client",
"layer", rst.Layer,
"client", client.Name,
"tx", "0x"+hex.EncodeToString(rst.Tx.Id),
"count", count,
tctx.Log.Desugar().Debug("received transaction client",
zap.Uint32("layer", rst.Layer),
zap.String("client", client.Name),
zap.String("tx", "0x"+hex.EncodeToString(rst.Tx.Id)),
zap.Int("count", count),
)
return len(txs[i]) < expectedCount, nil
},
)
if err != nil {
tctx.Log.Desugar().Error("watching transaction results",
zap.String("client", client.Name),
zap.Error(err),
)
return fmt.Errorf("watching transaction results for %s: %w", client.Name, err)
}
tctx.Log.Desugar().Debug("finished watching transaction results", zap.String("client", client.Name))
return nil
})
}
require.NoError(tb, eg.Wait())
Expand Down

0 comments on commit 138e9bd

Please sign in to comment.