Skip to content

Commit

Permalink
Fix logging issues in TestSpacemeshApp_NodeService
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Aug 1, 2023
1 parent c3b7250 commit 0a94619
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
16 changes: 3 additions & 13 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import (
"github.com/spacemeshos/go-spacemesh/log/logtest"
"github.com/spacemeshos/go-spacemesh/p2p"
"github.com/spacemeshos/go-spacemesh/signing"
"github.com/spacemeshos/go-spacemesh/timesync"
)

const layersPerEpoch = 3
Expand Down Expand Up @@ -410,8 +409,8 @@ func TestSpacemeshApp_JsonService(t *testing.T) {

// E2E app test of the stream endpoints in the NodeService.
func TestSpacemeshApp_NodeService(t *testing.T) {
logger := logtest.New(t)
errlog := log.RegisterHooks(logtest.New(t, zap.ErrorLevel), events.EventHook()) // errlog is used to simulate errors in the app
logger := logtest.New(t, zap.DebugLevel)
errlog := log.RegisterHooks(logtest.New(t, zap.DebugLevel), events.EventHook()) // errlog is used to simulate errors in the app

// Use a unique port
port := 1240
Expand All @@ -421,15 +420,6 @@ func TestSpacemeshApp_NodeService(t *testing.T) {
app.Config.SMESHING.CoinbaseAccount = types.GenerateAddress([]byte{1}).String()
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(logger),
)
require.NoError(t, err)
app.clock = clock

edSgn, err := signing.NewEdSigner()
require.NoError(t, err)
app.edSgn = edSgn
Expand All @@ -452,7 +442,7 @@ func TestSpacemeshApp_NodeService(t *testing.T) {

// Speed things up a little
app.Config.Sync.Interval = time.Second
app.Config.LayerDuration = 2 * time.Second
app.Config.LayerDuration = 5 * time.Second
app.Config.DataDirParent = t.TempDir()

// This will block. We need to run the full app here to make sure that
Expand Down
3 changes: 3 additions & 0 deletions p2p/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"sync"
"time"

lp2plog "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"go.uber.org/zap/zapcore"
"golang.org/x/sync/errgroup"

"github.com/spacemeshos/go-spacemesh/log"
Expand Down Expand Up @@ -194,5 +196,6 @@ func (fh *Host) Stop() error {
if err := fh.Host.Close(); err != nil {
return fmt.Errorf("failed to close libp2p host: %w", err)
}
lp2plog.SetPrimaryCore(zapcore.NewNopCore())
return nil
}

0 comments on commit 0a94619

Please sign in to comment.