fix require condition to be correct

This commit is contained in:
William Banfield
2022-05-12 14:48:23 -04:00
parent 5e4575695d
commit eec438ac97
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -2764,7 +2764,7 @@ func (cs *State) calculateProposalTimestampDifferenceMetric() {
func (cs *State) requireVoteExtension() bool {
requireHeight := cs.state.ConsensusParams.Vote.ExtensionRequireHeight
if requireHeight < cs.Height {
if requireHeight == 0 || cs.Height < requireHeight {
return false
}
return true
+9
View File
@@ -2260,6 +2260,9 @@ func TestPrepareProposalReceivesVoteExtensions(t *testing.T) {
}
}
// TestVoteExtensionRequiredHeight tests that 'ExtensionRequireHeight' correctly
// enforces that vote extensions be present in consensus for heights greater than
// or equal to the configured value.
func TestVoteExtensionRequiredHeight(t *testing.T) {
for _, testCase := range []struct {
name string
@@ -2291,6 +2294,12 @@ func TestVoteExtensionRequiredHeight(t *testing.T) {
initialRequiredHeight: 1,
expectSuccessfulRound: false,
},
{
name: "extension absent but required in future height",
hasExtension: false,
initialRequiredHeight: 2,
expectSuccessfulRound: true,
},
} {
t.Run(testCase.name, func(t *testing.T) {
config := configSetup(t)