mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 03:51:29 +00:00
Fix countdown timer (#9484)
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
parent
c45fe5cc1c
commit
f319535af5
@ -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
|
||||
|
@ -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")
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user