mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-30 19:51:58 +00:00
Import keystore logic from light-client
This commit is contained in:
41
cryptostore/storage_test.go
Normal file
41
cryptostore/storage_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package cryptostore
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
keys "github.com/tendermint/go-keys"
|
||||
)
|
||||
|
||||
func TestSortKeys(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
gen := GenEd25519.Generate
|
||||
assert.NotEqual(gen(), gen())
|
||||
|
||||
// alphabetical order is n3, n1, n2
|
||||
n1, n2, n3 := "john", "mike", "alice"
|
||||
infos := keys.KeyInfos{
|
||||
info(n1, gen()),
|
||||
info(n2, gen()),
|
||||
info(n3, gen()),
|
||||
}
|
||||
|
||||
// make sure they are initialized unsorted
|
||||
assert.Equal(n1, infos[0].Name)
|
||||
assert.Equal(n2, infos[1].Name)
|
||||
assert.Equal(n3, infos[2].Name)
|
||||
|
||||
// now they are sorted
|
||||
infos.Sort()
|
||||
assert.Equal(n3, infos[0].Name)
|
||||
assert.Equal(n1, infos[1].Name)
|
||||
assert.Equal(n2, infos[2].Name)
|
||||
|
||||
// make sure info put some real data there...
|
||||
assert.NotEmpty(infos[0].PubKey)
|
||||
assert.NotEmpty(infos[0].PubKey.Address())
|
||||
assert.NotEmpty(infos[1].PubKey)
|
||||
assert.NotEmpty(infos[1].PubKey.Address())
|
||||
assert.NotEqual(infos[0].PubKey, infos[1].PubKey)
|
||||
}
|
Reference in New Issue
Block a user