Skip to content

Commit

Permalink
Fix Test_votesTracker_getMessagesForBlockHash
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Apr 25, 2022
1 parent f3c3a89 commit 4e14e7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/grandpa/tracker_votes.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (vt *votesTracker) delete(blockHash common.Hash) {

// getMessagesForBlockHash returns all the vote messages
// for a particular block hash from the tracker as a slice
// of networkVoteMessage.
// of networkVoteMessage. There is no order in the slice.
// It returns nil if the block hash does not exist.
func (vt *votesTracker) getMessagesForBlockHash(
blockHash common.Hash) (messages []networkVoteMessage) {
Expand Down
7 changes: 7 additions & 0 deletions lib/grandpa/tracker_votes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ func Test_votesTracker_getMessagesForBlockHash(t *testing.T) {
vt := testCase.votesTracker
messages := vt.getMessagesForBlockHash(testCase.blockHash)

sort.Slice(messages, func(i, j int) bool {
if messages[i].from == messages[j].from {
return messages[i].msg.Round < messages[j].msg.Round
}
return messages[i].from < messages[j].from
})

assert.Equal(t, testCase.messages, messages)
})
}
Expand Down

0 comments on commit 4e14e7e

Please sign in to comment.