diff --git a/shared/slotutil/countdown.go b/shared/slotutil/countdown.go index 15ef0308d..19e6f11f0 100644 --- a/shared/slotutil/countdown.go +++ b/shared/slotutil/countdown.go @@ -41,14 +41,14 @@ func CountdownToGenesis(ctx context.Context, genesisTime time.Time, genesisValid ticker = time.NewTicker(time.Second) secondTimerActivated = true } + if timeRemaining >= time.Second { + log.WithFields(logFields).Infof( + "%s until chain genesis", + timeRemaining.Truncate(time.Second), + ) + } select { case <-ticker.C: - if timeRemaining >= time.Second { - log.WithFields(logFields).Infof( - "%s until chain genesis", - timeRemaining.Truncate(time.Second), - ) - } case <-ctx.Done(): log.Debug("Context closed, exiting routine") return diff --git a/shared/slotutil/countdown_test.go b/shared/slotutil/countdown_test.go index ca010c861..a0ee93aa6 100644 --- a/shared/slotutil/countdown_test.go +++ b/shared/slotutil/countdown_test.go @@ -8,10 +8,13 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/testutil/require" "github.com/prysmaticlabs/prysm/shared/timeutils" + "github.com/sirupsen/logrus" logTest "github.com/sirupsen/logrus/hooks/test" ) func TestCountdownToGenesis(t *testing.T) { + logrus.SetLevel(logrus.DebugLevel) + hook := logTest.NewGlobal() params.SetupTestConfigCleanup(t) config := params.BeaconConfig() @@ -47,6 +50,7 @@ func TestCountdownToGenesis(t *testing.T) { [32]byte{}, ) require.LogsContain(t, hook, "4s until chain genesis") + require.LogsContain(t, hook, "3s until chain genesis") require.LogsContain(t, hook, "Context closed, exiting routine") require.LogsDoNotContain(t, hook, "Chain genesis time reached") })