Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Dec 19, 2024
1 parent 2a4d56b commit 2050627
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
2 changes: 0 additions & 2 deletions api/grpcserver/mesh_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,12 @@ func TestMeshService_MalfeasanceStream(t *testing.T) {

id, proof := AtxMalfeasance(t, db)
proofBytes := codec.MustEncode(proof)
require.NoError(t, identities.SetMalicious(db, id, proofBytes, time.Now()))
events.ReportMalfeasance(id)
resp, err := stream.Recv()
require.NoError(t, err)
require.Equal(t, toMalfeasancePB(id, proofBytes, false), resp.Proof)
id, proof = BallotMalfeasance(t, db)
proofBytes = codec.MustEncode(proof)
require.NoError(t, identities.SetMalicious(db, id, proofBytes, time.Now()))
events.ReportMalfeasance(id)
resp, err = stream.Recv()
require.NoError(t, err)
Expand Down
25 changes: 2 additions & 23 deletions api/grpcserver/v2alpha1/v2alpha1_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package v2alpha1

import (
"context"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials/insecure"

"github.com/spacemeshos/go-spacemesh/api/grpcserver"
Expand All @@ -22,9 +20,7 @@ const (

func launchServer(tb testing.TB, services ...grpcserver.ServiceAPI) (grpcserver.Config, func()) {
cfg := grpcserver.DefaultTestConfig()
// logger := zaptest.NewLogger(tb).Named("grpc")
logger := zap.NewNop()
grpc, err := grpcserver.NewWithServices(cfg.PublicListener, logger, cfg, services)
grpc, err := grpcserver.NewWithServices(cfg.PublicListener, zaptest.NewLogger(tb).Named("grpc"), cfg, services)
require.NoError(tb, err)

// start gRPC server
Expand All @@ -44,23 +40,6 @@ func dialGrpc(tb testing.TB, cfg grpcserver.Config) *grpc.ClientConn {
)
require.NoError(tb, err)

// block until the clientConn is ready.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
for {
s := conn.GetState()
if s == connectivity.Ready {
break
}
if s == connectivity.Idle {
conn.Connect()
}
if !conn.WaitForStateChange(ctx, s) {
tb.Fatalf("timeout waiting for connection to %s", conn.Target())
return nil
}
}

tb.Cleanup(func() { require.NoError(tb, conn.Close()) })
return conn
}

0 comments on commit 2050627

Please sign in to comment.