Skip to content

Commit

Permalink
Fixed all failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-mena authored and greg-szabo committed Nov 26, 2024
1 parent d8b2ec9 commit 4487393
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions consensus/invalid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func invalidDoPrevoteFunc(t *testing.T, cs *State, sw *p2p.Switch, pv types.Priv
}
precommit.Signature = p.Signature
precommit.ExtensionSignature = p.ExtensionSignature
precommit.NonRpExtension = p.NonRpExtension
precommit.NonRpExtensionSignature = p.NonRpExtensionSignature
cs.privValidator = nil // disable priv val so we don't do normal votes

peers := sw.Peers().List()
Expand Down
3 changes: 2 additions & 1 deletion evidence/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ func makeExtCommit(height int64, valAddr []byte) *types.ExtendedCommit {
Timestamp: defaultEvidenceTime,
Signature: []byte("Signature"),
},
ExtensionSignature: []byte("Extended Signature"),
ExtensionSignature: []byte("Extended Signature"),
NonRpExtensionSignature: []byte("Non Replay Protected Extended Signature"),
}},
}
}
Expand Down
3 changes: 2 additions & 1 deletion store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func makeTestExtCommitWithNumSigs(height int64, timestamp time.Time, numSigs int
Timestamp: timestamp,
Signature: cmtrand.Bytes(64),
},
ExtensionSignature: []byte("ExtensionSignature"),
ExtensionSignature: []byte("ExtensionSignature"),
NonRpExtensionSignature: []byte("NonRpExtensionSignature"),
})
}
return &types.ExtendedCommit{
Expand Down
14 changes: 11 additions & 3 deletions types/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func examplePrecommit() *Vote {
vote := exampleVote(byte(cmtproto.PrecommitType))
vote.Extension = []byte("extension")
vote.ExtensionSignature = []byte("signature")
vote.NonRpExtension = []byte("non_replay_protected_extension")
vote.NonRpExtensionSignature = []byte("non_replay_protected_extension_signature")
return vote
}

Expand Down Expand Up @@ -315,7 +317,7 @@ func TestVoteVerify(t *testing.T) {

func TestVoteString(t *testing.T) {
str := examplePrecommit().String()
expected := `Vote{56789:6AF1F4111082 12345/02/SIGNED_MSG_TYPE_PRECOMMIT(Precommit) 8B01023386C3 000000000000 657874656E73 000000000000 @ 2017-12-25T03:00:01.234Z}` //nolint:lll //ignore line length for tests
expected := `Vote{56789:6AF1F4111082 12345/02/SIGNED_MSG_TYPE_PRECOMMIT(Precommit) 8B01023386C3 000000000000 657874656E73 6E6F6E5F7265 @ 2017-12-25T03:00:01.234Z}` //nolint:lll //ignore line length for tests
if str != expected {
t.Errorf("got unexpected string for Vote. Expected:\n%v\nGot:\n%v", expected, str)
}
Expand Down Expand Up @@ -345,8 +347,14 @@ func TestValidVotes(t *testing.T) {
malleateVote func(*Vote)
}{
{"good prevote", examplePrevote(), func(v *Vote) {}},
{"good precommit without vote extension", examplePrecommit(), func(v *Vote) { v.Extension = nil }},
{"good precommit with vote extension", examplePrecommit(), func(v *Vote) { v.Extension = []byte("extension") }},
{"good precommit without vote extension", examplePrecommit(), func(v *Vote) {
v.Extension = nil
v.NonRpExtension = nil
}},
{"good precommit with vote extension", examplePrecommit(), func(v *Vote) {
v.Extension = []byte("extension")
v.NonRpExtension = []byte("non_replay_protected_extension")
}},
}
for _, tc := range testCases {
signVote(t, privVal, "test_chain_id", tc.vote)
Expand Down

0 comments on commit 4487393

Please sign in to comment.