Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ConvallariaMaj committed Jul 23, 2024
1 parent dee9103 commit 735f318
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
6 changes: 3 additions & 3 deletions activation/poetdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestPoetDbHappyFlow(t *testing.T) {
msg := getPoetProof(t)
poetDb := NewPoetDb(sql.InMemory(), zaptest.NewLogger(t))

r.NoError(poetDb.Validate(msg.Statement[:], msg.PoetProof, msg.PoetServiceID, msg.RoundID, types.EmptyEdSignature))
r.NoError(poetDb.Validate(msg.Statement[:], msg.PoetProof, msg.PoetServiceID, msg.RoundID))
ref, err := msg.Ref()
r.NoError(err)

Expand All @@ -86,7 +86,7 @@ func TestPoetDbInvalidPoetProof(t *testing.T) {
poetDb := NewPoetDb(sql.InMemory(), zaptest.NewLogger(t))
msg.PoetProof.Root = []byte("some other root")

err := poetDb.Validate(msg.Statement[:], msg.PoetProof, msg.PoetServiceID, msg.RoundID, types.EmptyEdSignature)
err := poetDb.Validate(msg.Statement[:], msg.PoetProof, msg.PoetServiceID, msg.RoundID)
r.EqualError(
err,
fmt.Sprintf(
Expand All @@ -102,7 +102,7 @@ func TestPoetDbInvalidPoetStatement(t *testing.T) {
poetDb := NewPoetDb(sql.InMemory(), zaptest.NewLogger(t))
msg.Statement = types.CalcHash32([]byte("some other statement"))

err := poetDb.Validate(msg.Statement[:], msg.PoetProof, msg.PoetServiceID, msg.RoundID, types.EmptyEdSignature)
err := poetDb.Validate(msg.Statement[:], msg.PoetProof, msg.PoetServiceID, msg.RoundID)
r.EqualError(
err,
fmt.Sprintf(
Expand Down
5 changes: 1 addition & 4 deletions api/grpcserver/globalstate_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"math"
"testing"
"time"

pb "github.com/spacemeshos/api/release/go/spacemesh/v1"
"github.com/stretchr/testify/require"
Expand All @@ -30,9 +29,7 @@ func setupGlobalStateService(t *testing.T) (*globalStateServiceConn, context.Con
cfg, cleanup := launchServer(t, svc)
t.Cleanup(cleanup)

grpcCtx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
conn := dialGrpc(grpcCtx, t, cfg)
conn := dialGrpc(t, cfg)
client := pb.NewGlobalStateServiceClient(conn)

return &globalStateServiceConn{
Expand Down
18 changes: 8 additions & 10 deletions api/grpcserver/grpcserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,6 @@ func TestAccountMeshDataStream_comprehensive(t *testing.T) {
cfg, cleanup := launchServer(t, grpcService)
t.Cleanup(cleanup)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(t, cfg)
c := pb.NewMeshServiceClient(conn)

Expand All @@ -1688,7 +1686,7 @@ func TestAccountMeshDataStream_comprehensive(t *testing.T) {
},
}

ctx, cancel = context.WithTimeout(context.Background(), time.Second)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
stream, err := c.AccountMeshDataStream(ctx, req)
require.NoError(t, err, "stream request returned unexpected error")
Expand Down Expand Up @@ -1723,8 +1721,6 @@ func TestAccountDataStream_comprehensive(t *testing.T) {
cfg, cleanup := launchServer(t, svc)
t.Cleanup(cleanup)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(t, cfg)
c := pb.NewGlobalStateServiceClient(conn)

Expand All @@ -1739,7 +1735,7 @@ func TestAccountDataStream_comprehensive(t *testing.T) {
},
}

ctx, cancel = context.WithTimeout(context.Background(), time.Second)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
stream, err := c.AccountDataStream(ctx, req)
require.NoError(t, err, "stream request returned unexpected error")
Expand Down Expand Up @@ -1783,8 +1779,6 @@ func TestGlobalStateStream_comprehensive(t *testing.T) {
cfg, cleanup := launchServer(t, svc)
t.Cleanup(cleanup)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(t, cfg)
c := pb.NewGlobalStateServiceClient(conn)

Expand All @@ -1796,6 +1790,9 @@ func TestGlobalStateStream_comprehensive(t *testing.T) {
pb.GlobalStateDataFlag_GLOBAL_STATE_DATA_FLAG_REWARD),
}

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

stream, err := c.GlobalStateStream(ctx, req)
require.NoError(t, err, "stream request returned unexpected error")
// Give the server-side time to subscribe to events
Expand Down Expand Up @@ -1858,12 +1855,13 @@ func TestLayerStream_comprehensive(t *testing.T) {
cfg, cleanup := launchServer(t, grpcService)
t.Cleanup(cleanup)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := dialGrpc(t, cfg)

// set up the grpc listener stream
c := pb.NewMeshServiceClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
stream, err := c.LayerStream(ctx, &pb.LayerStreamRequest{})
require.NoError(t, err, "stream request returned unexpected error")
// Give the server-side time to subscribe to events
Expand Down
3 changes: 2 additions & 1 deletion api/grpcserver/node_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package grpcserver

import (
"context"
"testing"

pb "github.com/spacemeshos/api/release/go/spacemesh/v1"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"testing"

"github.com/spacemeshos/go-spacemesh/common/types"
)
Expand Down
5 changes: 2 additions & 3 deletions api/grpcserver/transaction_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ func parseOk() parseExpectation {

func TestParseTransactions(t *testing.T) {
db := sql.InMemory()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
t.Cleanup(cancel)

vminst := vm.New(db)
cfg, cleanup := launchServer(t, NewTransactionService(db, nil, nil, txs.NewConservativeState(vminst, db), nil, nil))
t.Cleanup(cleanup)
Expand All @@ -232,7 +231,7 @@ func TestParseTransactions(t *testing.T) {
for i := range keys {
pub, priv, err := ed25519.GenerateKey(rng)
require.NoError(t, err)
keys[i] = signing.PrivateKey(priv)
keys[i] = priv
accounts[i] = types.Account{Address: wallet.Address(pub), Balance: 1e12}
}
require.NoError(t, vminst.ApplyGenesis(accounts))
Expand Down

0 comments on commit 735f318

Please sign in to comment.