diff --git a/consensus/posv/posv.go b/consensus/posv/posv.go index 24cb26d059..6804f348d5 100644 --- a/consensus/posv/posv.go +++ b/consensus/posv/posv.go @@ -447,6 +447,9 @@ func (c *Posv) verifyCascadingFields(chain consensus.ChainReader, header *types. // compare 2 signers lists // return true if they are same elements, otherwise return false func compareSignersLists(list1 []common.Address, list2 []common.Address) bool { + if len(list1) == 0 && len(list2) == 0 { + return true + } sort.Slice(list1, func(i, j int) bool { return list1[i].String() <= list1[j].String() }) diff --git a/consensus/posv/posv_test.go b/consensus/posv/posv_test.go index 1ccf9f7860..56c94e7521 100644 --- a/consensus/posv/posv_test.go +++ b/consensus/posv/posv_test.go @@ -72,4 +72,13 @@ func TestCompareSignersLists(t *testing.T) { if compareSignersLists(list1, list3) { t.Error("list1 and list3 should not be same", "list1", list1, "list3", list3) } + if !compareSignersLists([]common.Address{}, []common.Address{}) { + t.Error("Failed with empty list") + } + if !compareSignersLists([]common.Address{common.StringToAddress("cccccccccccccccccccccccccccccccccccccccc")}, []common.Address{common.StringToAddress("cccccccccccccccccccccccccccccccccccccccc")}) { + t.Error("Failed with list has only one signer") + } + if compareSignersLists([]common.Address{common.StringToAddress("aaaaaaaaaaaaaaaa")}, []common.Address{common.StringToAddress("cccccccccccccccccccccccccccccccccccccccc")}) { + t.Error("Failed with list has only one signer") + } }