solved sorting issue in getVoteAccounts test
This commit is contained in:
parent
cb8422c563
commit
7d194b72b9
|
@ -168,7 +168,6 @@ func (s *MockServer) getResult(method string, params ...any) (any, *RPCError) {
|
|||
rewards := make([]map[string]int, len(addresses))
|
||||
for i, item := range addresses {
|
||||
address := item.(string)
|
||||
// TODO: make inflation rewards fetchable by epoch
|
||||
rewards[i] = map[string]int{"amount": s.inflationRewards[address], "epoch": epoch}
|
||||
}
|
||||
return rewards, nil
|
||||
|
|
|
@ -3,6 +3,7 @@ package rpc
|
|||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -130,7 +131,10 @@ func TestMockServer_getVoteAccounts(t *testing.T) {
|
|||
|
||||
voteAccounts, err := client.GetVoteAccounts(ctx, CommitmentFinalized)
|
||||
assert.NoError(t, err)
|
||||
// TODO: this test sometimes (albeit rarely) fails because the ordering gets mixed up, fix!
|
||||
// sort the vote accounts before comparing:
|
||||
sort.Slice(voteAccounts.Current, func(i, j int) bool {
|
||||
return voteAccounts.Current[i].VotePubkey < voteAccounts.Current[j].VotePubkey
|
||||
})
|
||||
assert.Equal(t,
|
||||
VoteAccounts{
|
||||
Current: []VoteAccount{
|
||||
|
|
Loading…
Reference in New Issue