mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-28 14:47:16 +00:00
da3c239ed6
* Add nodeInfo * Remove interfaces for replacement Signed-off-by: Dmitry Savelev <darksawa@gmail.com> * Squashed 'interfaces/' content from commit 67abfdd git-subtree-dir: interfaces git-subtree-split: 67abfdd23b3bbef0d2f0c038275b6f47820d7f5e
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)
|
|
})
|
|
}
|
|
}
|