Validator nil duty should not panic (#8171)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terence tsao
2021-01-04 09:28:00 -08:00
committed by GitHub
parent 7c25d5c852
commit bf673ecb12
2 changed files with 10 additions and 0 deletions

View File

@@ -43,6 +43,9 @@ func (v *validator) LogNextDutyTimeLeft(slot uint64) error {
if !v.logDutyCountDown {
return nil
}
if v.duties == nil {
return nil
}
var nextDutySlot uint64
var role string

View File

@@ -49,3 +49,10 @@ func TestLogNextDutyCountDown_HasDutyProposer(t *testing.T) {
require.NoError(t, v.LogNextDutyTimeLeft(101))
require.LogsContain(t, hook, "\"Next duty\" currentSlot=101 dutySlot=105 prefix=validator role=proposer")
}
func TestLogNextDutyCountDown_NilDuty(t *testing.T) {
v := &validator{
logDutyCountDown: true,
}
require.NoError(t, v.LogNextDutyTimeLeft(101))
}