6 "github.com/stretchr/testify/assert"
8 crypto "github.com/tendermint/go-crypto"
9 cmn "github.com/tendermint/tmlibs/common"
11 keys "github.com/tendermint/go-crypto/keys"
14 func TestSortKeys(t *testing.T) {
15 assert := assert.New(t)
17 gen := func() crypto.PrivKey {
18 key, _ := GenEd25519.Generate(cmn.RandBytes(16))
21 assert.NotEqual(gen(), gen())
23 // alphabetical order is n3, n1, n2
24 n1, n2, n3 := "john", "mike", "alice"
31 // make sure they are initialized unsorted
32 assert.Equal(n1, infos[0].Name)
33 assert.Equal(n2, infos[1].Name)
34 assert.Equal(n3, infos[2].Name)
36 // now they are sorted
38 assert.Equal(n3, infos[0].Name)
39 assert.Equal(n1, infos[1].Name)
40 assert.Equal(n2, infos[2].Name)
42 // make sure info put some real data there...
43 assert.NotEmpty(infos[0].PubKey)
44 assert.NotEmpty(infos[0].PubKey.Address())
45 assert.NotEmpty(infos[1].PubKey)
46 assert.NotEmpty(infos[1].PubKey.Address())
47 assert.NotEqual(infos[0].PubKey, infos[1].PubKey)