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))
|
rewards := make([]map[string]int, len(addresses))
|
||||||
for i, item := range addresses {
|
for i, item := range addresses {
|
||||||
address := item.(string)
|
address := item.(string)
|
||||||
// TODO: make inflation rewards fetchable by epoch
|
|
||||||
rewards[i] = map[string]int{"amount": s.inflationRewards[address], "epoch": epoch}
|
rewards[i] = map[string]int{"amount": s.inflationRewards[address], "epoch": epoch}
|
||||||
}
|
}
|
||||||
return rewards, nil
|
return rewards, nil
|
||||||
|
|
|
@ -3,6 +3,7 @@ package rpc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -130,7 +131,10 @@ func TestMockServer_getVoteAccounts(t *testing.T) {
|
||||||
|
|
||||||
voteAccounts, err := client.GetVoteAccounts(ctx, CommitmentFinalized)
|
voteAccounts, err := client.GetVoteAccounts(ctx, CommitmentFinalized)
|
||||||
assert.NoError(t, err)
|
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,
|
assert.Equal(t,
|
||||||
VoteAccounts{
|
VoteAccounts{
|
||||||
Current: []VoteAccount{
|
Current: []VoteAccount{
|
||||||
|
|
Loading…
Reference in New Issue