mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
ff64fdcfb5
* Add a flag to enable count down * Add tests
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func TestLogNextDutyCountDown_NoDuty(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
v := &validator{
|
|
logDutyCountDown: true,
|
|
duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{
|
|
{AttesterSlot: 100, ProposerSlots: []uint64{105}},
|
|
{AttesterSlot: 110},
|
|
{AttesterSlot: 120},
|
|
}},
|
|
}
|
|
require.NoError(t, v.LogNextDutyTimeLeft(121))
|
|
require.LogsContain(t, hook, "No duty until next epoch")
|
|
}
|
|
|
|
func TestLogNextDutyCountDown_HasDutyAttester(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
v := &validator{
|
|
logDutyCountDown: true,
|
|
duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{
|
|
{AttesterSlot: 100, ProposerSlots: []uint64{105}},
|
|
{AttesterSlot: 110},
|
|
{AttesterSlot: 120},
|
|
}},
|
|
}
|
|
require.NoError(t, v.LogNextDutyTimeLeft(115))
|
|
require.LogsContain(t, hook, "\"Next duty\" currentSlot=115 dutySlot=120 prefix=validator role=attester")
|
|
}
|
|
|
|
func TestLogNextDutyCountDown_HasDutyProposer(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
v := &validator{
|
|
logDutyCountDown: true,
|
|
duties: ðpb.DutiesResponse{CurrentEpochDuties: []*ethpb.DutiesResponse_Duty{
|
|
{AttesterSlot: 100, ProposerSlots: []uint64{105}},
|
|
{AttesterSlot: 110},
|
|
{AttesterSlot: 120},
|
|
}},
|
|
}
|
|
require.NoError(t, v.LogNextDutyTimeLeft(101))
|
|
require.LogsContain(t, hook, "\"Next duty\" currentSlot=101 dutySlot=105 prefix=validator role=proposer")
|
|
}
|