Skip to content

Commit 4e14e7e

Browse files
committed
Fix Test_votesTracker_getMessagesForBlockHash
1 parent f3c3a89 commit 4e14e7e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/grandpa/tracker_votes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (vt *votesTracker) delete(blockHash common.Hash) {
146146

147147
// getMessagesForBlockHash returns all the vote messages
148148
// for a particular block hash from the tracker as a slice
149-
// of networkVoteMessage.
149+
// of networkVoteMessage. There is no order in the slice.
150150
// It returns nil if the block hash does not exist.
151151
func (vt *votesTracker) getMessagesForBlockHash(
152152
blockHash common.Hash) (messages []networkVoteMessage) {

lib/grandpa/tracker_votes_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ func Test_votesTracker_getMessagesForBlockHash(t *testing.T) {
308308
vt := testCase.votesTracker
309309
messages := vt.getMessagesForBlockHash(testCase.blockHash)
310310

311+
sort.Slice(messages, func(i, j int) bool {
312+
if messages[i].from == messages[j].from {
313+
return messages[i].msg.Round < messages[j].msg.Round
314+
}
315+
return messages[i].from < messages[j].from
316+
})
317+
311318
assert.Equal(t, testCase.messages, messages)
312319
})
313320
}

0 commit comments

Comments
 (0)