|
|
@ -8,6 +8,7 @@ import ( |
|
|
|
"github.com/stretchr/testify/require" |
|
|
|
"github.com/tendermint/tendermint/crypto" |
|
|
|
"github.com/tendermint/tendermint/crypto/ed25519" |
|
|
|
"github.com/tendermint/tendermint/crypto/multisig" |
|
|
|
"github.com/tendermint/tendermint/crypto/secp256k1" |
|
|
|
) |
|
|
|
|
|
|
@ -127,3 +128,24 @@ func TestPubKeyInvalidDataProperReturnsEmpty(t *testing.T) { |
|
|
|
require.NotNil(t, err, "expecting a non-nil error") |
|
|
|
require.Nil(t, pk, "expecting an empty public key on error") |
|
|
|
} |
|
|
|
|
|
|
|
func TestPubkeyAminoRoute(t *testing.T) { |
|
|
|
tests := []struct { |
|
|
|
key crypto.PubKey |
|
|
|
want string |
|
|
|
wantErr bool |
|
|
|
}{ |
|
|
|
{ed25519.PubKeyEd25519{}, ed25519.PubKeyAminoRoute, false}, |
|
|
|
{secp256k1.PubKeySecp256k1{}, secp256k1.PubKeyAminoRoute, false}, |
|
|
|
{&multisig.PubKeyMultisigThreshold{}, multisig.PubKeyMultisigThresholdAminoRoute, false}, |
|
|
|
} |
|
|
|
for i, tc := range tests { |
|
|
|
got, err := PubkeyAminoRoute(cdc, tc.key) |
|
|
|
if tc.wantErr { |
|
|
|
require.Error(t, err, "tc %d", i) |
|
|
|
} else { |
|
|
|
require.NoError(t, err, "tc %d", i) |
|
|
|
require.Equal(t, tc.want, got, "tc %d", i) |
|
|
|
} |
|
|
|
} |
|
|
|
} |