Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Nov 25, 2024
1 parent 0411230 commit 0b6a03b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion systest/testcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var (
1,
"controls tests parallelization by creating multiple spacemesh clusters at the same time",
)
logLevel = zap.LevelFlag("level", zap.DebugLevel, "verbosity of the logger")
logLevel = zap.LevelFlag("level", zap.InfoLevel, "verbosity of the logger")
testTimeout = flag.Duration("test-timeout", 60*time.Minute, "timeout for a single test")

tokens chan struct{}
Expand Down
6 changes: 3 additions & 3 deletions systest/tests/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ func TestCheckpoint(t *testing.T) {
deadline := cl.Genesis().Add(time.Duration(stop+1) * layerDuration)
ctx, cancel := context.WithDeadline(tctx, deadline)
defer cancel()

require.NoError(t, sendTransactions(ctx, tctx.Log.Desugar(), cl, first, stop, layerDuration, receiver, 1, 100))
require.NoError(t, sendTransactions(ctx, tctx.Log.Desugar(), cl, first, stop, receiver, 1, 100))
require.NoError(t, waitLayer(tctx, cl.Client(0), snapshotLayer))

tctx.Log.Debugw("getting account balances")
Expand Down Expand Up @@ -102,7 +101,8 @@ func TestCheckpoint(t *testing.T) {
diffs = append(diffs, cl.Client(i).Name)
tctx.Log.Errorw("diff checkpoint data",
fmt.Sprintf("reference %v", cl.Client(0).Name), string(checkpoints[0]),
fmt.Sprintf("client %v", cl.Client(i).Name), string(checkpoints[i]))
fmt.Sprintf("client %v", cl.Client(i).Name), string(checkpoints[i]),
)
}
}
require.Empty(t, diffs)
Expand Down
1 change: 0 additions & 1 deletion systest/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func sendTransactions(
logger *zap.Logger,
cl *cluster.Cluster,
first, stop uint32,
layerDuration time.Duration,
receiver types.Address,
batch, amount int,
) error {
Expand Down
8 changes: 6 additions & 2 deletions systest/tests/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"testing"
"time"

pb "github.com/spacemeshos/api/release/go/spacemesh/v1"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -60,12 +61,15 @@ func testPartition(tb testing.TB, tctx *testcontext.Context, cl *cluster.Cluster

// start sending transactions
tctx.Log.Debug("sending transactions...")
eg2, ctx2 := errgroup.WithContext(tctx)
receiver := types.GenerateAddress([]byte{11, 1, 1})

layerDuration := testcontext.LayerDuration.Get(tctx.Parameters)
deadline := cl.Genesis().Add(time.Duration(stop) * layerDuration)
ctx2, cancel := context.WithDeadline(tctx, deadline)
eg2, ctx2 := errgroup.WithContext(ctx2)
defer cancel()
eg2.Go(func() error {
return sendTransactions(ctx2, tctx.Log.Desugar(), cl, first, stop, layerDuration, receiver, 10, 100)
return sendTransactions(ctx2, tctx.Log.Desugar(), cl, first, stop, receiver, 10, 100)
})

type stateUpdate struct {
Expand Down
11 changes: 8 additions & 3 deletions systest/tests/transactions_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package tests

import (
"context"
"encoding/hex"
"testing"
"time"

pb "github.com/spacemeshos/api/release/go/spacemesh/v1"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -44,16 +46,19 @@ func testTransactions(
require.NoError(tb, err)
before := response.AccountWrapper.StateCurrent.Balance

eg, ctx := errgroup.WithContext(tctx)
layerDuration := testcontext.LayerDuration.Get(tctx.Parameters)
deadline := cl.Genesis().Add(time.Duration(stop) * layerDuration)
ctx, cancel := context.WithDeadline(tctx, deadline)
defer cancel()
eg, ctx := errgroup.WithContext(ctx)
eg.Go(func() error {
return sendTransactions(ctx, tctx.Log.Desugar(), cl, first, stop, layerDuration, receiver, batch, amount)
return sendTransactions(ctx, tctx.Log.Desugar(), cl, first, stop, receiver, batch, amount)
})
txs := make([][]*pb.Transaction, cl.Total())

for i := range cl.Total() {
client := cl.Client(i)
watchTransactionResults(tctx.Context, eg, client, tctx.Log.Desugar(),
watchTransactionResults(tctx, eg, client, tctx.Log.Desugar(),
func(rst *pb.TransactionResult) (bool, error) {
txs[i] = append(txs[i], rst.Tx)
count := len(txs[i])
Expand Down

0 comments on commit 0b6a03b

Please sign in to comment.