mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-29 07:07:16 +00:00
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
|
package remote_test
|
||
|
|
||
|
import (
|
||
|
"sort"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
|
||
|
"github.com/ledgerwatch/erigon-lib/gointerfaces/types"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestSort(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
got *remote.NodesInfoReply
|
||
|
want *remote.NodesInfoReply
|
||
|
}{
|
||
|
{
|
||
|
name: "sort by name",
|
||
|
got: &remote.NodesInfoReply{
|
||
|
NodesInfo: []*types.NodeInfoReply{
|
||
|
{Name: "b", Enode: "c"},
|
||
|
{Name: "a", Enode: "d"},
|
||
|
},
|
||
|
},
|
||
|
want: &remote.NodesInfoReply{
|
||
|
NodesInfo: []*types.NodeInfoReply{
|
||
|
{Name: "a", Enode: "d"},
|
||
|
{Name: "b", Enode: "c"},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
name: "sort by enode",
|
||
|
got: &remote.NodesInfoReply{
|
||
|
NodesInfo: []*types.NodeInfoReply{
|
||
|
{Name: "a", Enode: "d"},
|
||
|
{Name: "a", Enode: "c"},
|
||
|
},
|
||
|
},
|
||
|
want: &remote.NodesInfoReply{
|
||
|
NodesInfo: []*types.NodeInfoReply{
|
||
|
{Name: "a", Enode: "c"},
|
||
|
{Name: "a", Enode: "d"},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
|
||
|
sort.Sort(tt.got)
|
||
|
|
||
|
assert.Equal(t, tt.want, tt.got)
|
||
|
})
|
||
|
}
|
||
|
}
|