Skip to content

Commit

Permalink
Revert "Revert "fix flaky test: TestSpacemeshApp_NodeService (spaceme…
Browse files Browse the repository at this point in the history
…shos#4728)""

This reverts commit f87546d.
  • Loading branch information
dshulyak committed Jul 22, 2023
1 parent 8331894 commit acc86f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
12 changes: 9 additions & 3 deletions activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,19 @@ func (b *Builder) verifyInitialPost(ctx context.Context, post *types.Post, metad
if err != nil {
b.log.With().Panic("failed to fetch commitment ATX ID.", log.Err(err))
}
if err := b.validator.Post(ctx, types.EpochID(0), b.nodeID, commitmentAtxId, post, metadata, b.postSetupProvider.LastOpts().NumUnits); err != nil {
err = b.validator.Post(ctx, types.EpochID(0), b.nodeID, commitmentAtxId, post, metadata, b.postSetupProvider.LastOpts().NumUnits)
switch {
case errors.Is(err, context.Canceled):
// If the context was canceled, we don't want to emit or log errors just propagate the cancellation signal.
return err
case err != nil:
events.EmitInvalidPostProof()
b.log.With().Fatal("initial POST proof is invalid. Probably the initialized POST data is corrupted. Please verify the data with postcli and regenerate the corrupted files.", log.Err(err))
return err
default:
b.initialPost = post
return nil
}
b.initialPost = post
return nil
}

func (b *Builder) receivePendingPoetClients() *[]PoetProvingServiceClient {
Expand Down
3 changes: 2 additions & 1 deletion node/bad_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ func NewApp(conf *config.Config) (*App, error) {
WithConfig(conf),
WithLog(log.RegisterHooks(
log.NewWithLevel("", zap.NewAtomicLevelAt(zapcore.DebugLevel)),
events.EventHook())),
events.EventHook()),
),
)

var err error
Expand Down
4 changes: 4 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,10 @@ func (app *App) stopServices(ctx context.Context) {
}

events.CloseEventReporter()
// SetGrpcLogger unfortunately is global
// this ensures that a test-logger isn't used after the app shuts down
// by e.g. a grpc connection to the node that is still open - like in TestSpacemeshApp_NodeService
grpczap.SetGrpcLoggerV2(grpclog, log.NewNop().Zap())
}

// LoadOrCreateEdSigner either loads a previously created ed identity for the node or creates a new one if not exists.
Expand Down
4 changes: 2 additions & 2 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,13 @@ func TestSpacemeshApp_NodeService(t *testing.T) {
app := New(WithLog(logger))
app.Config = getTestDefaultConfig(t)
app.Config.SMESHING.CoinbaseAccount = types.GenerateAddress([]byte{1}).String()
app.Config.SMESHING.Opts.DataDir, _ = os.MkdirTemp("", "sm-app-test-post-datadir")
app.Config.SMESHING.Opts.DataDir = t.TempDir()

clock, err := timesync.NewClock(
timesync.WithLayerDuration(1*time.Second),
timesync.WithTickInterval(100*time.Millisecond),
timesync.WithGenesisTime(time.Now()),
timesync.WithLogger(logtest.New(t)),
timesync.WithLogger(logger),
)
require.NoError(t, err)
app.clock = clock
Expand Down

0 comments on commit acc86f7

Please sign in to comment.