2020-08-05 13:27:48 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2020-10-16 13:51:00 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/crypto/keys/hd"
|
2020-08-05 13:27:48 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetBech32Prefixes(t *testing.T) {
|
|
|
|
config := sdk.GetConfig()
|
2020-09-07 13:04:50 +00:00
|
|
|
|
2020-08-05 13:27:48 +00:00
|
|
|
require.Equal(t, sdk.Bech32PrefixAccAddr, config.GetBech32AccountAddrPrefix())
|
|
|
|
require.Equal(t, sdk.Bech32PrefixAccPub, config.GetBech32AccountPubPrefix())
|
|
|
|
require.Equal(t, sdk.Bech32PrefixValAddr, config.GetBech32ValidatorAddrPrefix())
|
|
|
|
require.Equal(t, sdk.Bech32PrefixValPub, config.GetBech32ValidatorPubPrefix())
|
|
|
|
require.Equal(t, sdk.Bech32PrefixConsAddr, config.GetBech32ConsensusAddrPrefix())
|
|
|
|
require.Equal(t, sdk.Bech32PrefixConsPub, config.GetBech32ConsensusPubPrefix())
|
|
|
|
|
|
|
|
SetBech32Prefixes(config)
|
|
|
|
require.Equal(t, Bech32PrefixAccAddr, config.GetBech32AccountAddrPrefix())
|
|
|
|
require.Equal(t, Bech32PrefixAccPub, config.GetBech32AccountPubPrefix())
|
|
|
|
require.Equal(t, Bech32PrefixValAddr, config.GetBech32ValidatorAddrPrefix())
|
|
|
|
require.Equal(t, Bech32PrefixValPub, config.GetBech32ValidatorPubPrefix())
|
|
|
|
require.Equal(t, Bech32PrefixConsAddr, config.GetBech32ConsensusAddrPrefix())
|
|
|
|
require.Equal(t, Bech32PrefixConsPub, config.GetBech32ConsensusPubPrefix())
|
2020-08-25 12:16:31 +00:00
|
|
|
|
|
|
|
require.Equal(t, sdk.GetConfig().GetBech32AccountAddrPrefix(), config.GetBech32AccountAddrPrefix())
|
|
|
|
require.Equal(t, sdk.GetConfig().GetBech32AccountPubPrefix(), config.GetBech32AccountPubPrefix())
|
|
|
|
require.Equal(t, sdk.GetConfig().GetBech32ValidatorAddrPrefix(), config.GetBech32ValidatorAddrPrefix())
|
|
|
|
require.Equal(t, sdk.GetConfig().GetBech32ValidatorPubPrefix(), config.GetBech32ValidatorPubPrefix())
|
|
|
|
require.Equal(t, sdk.GetConfig().GetBech32ConsensusAddrPrefix(), config.GetBech32ConsensusAddrPrefix())
|
|
|
|
require.Equal(t, sdk.GetConfig().GetBech32ConsensusPubPrefix(), config.GetBech32ConsensusPubPrefix())
|
2020-08-05 13:27:48 +00:00
|
|
|
}
|
2020-08-28 15:35:10 +00:00
|
|
|
|
|
|
|
func TestSetCoinType(t *testing.T) {
|
|
|
|
config := sdk.GetConfig()
|
|
|
|
require.Equal(t, sdk.CoinType, int(config.GetCoinType()))
|
2020-09-07 13:04:50 +00:00
|
|
|
require.Equal(t, sdk.FullFundraiserPath, config.GetFullFundraiserPath())
|
2020-08-28 15:35:10 +00:00
|
|
|
|
|
|
|
SetBip44CoinType(config)
|
|
|
|
require.Equal(t, Bip44CoinType, int(config.GetCoinType()))
|
|
|
|
require.Equal(t, sdk.GetConfig().GetCoinType(), config.GetCoinType())
|
2020-09-07 13:04:50 +00:00
|
|
|
require.Equal(t, sdk.GetConfig().GetFullFundraiserPath(), config.GetFullFundraiserPath())
|
2020-08-28 15:35:10 +00:00
|
|
|
}
|
2020-10-16 13:51:00 +00:00
|
|
|
|
|
|
|
func TestHDPath(t *testing.T) {
|
|
|
|
params := *hd.NewFundraiserParams(0, Bip44CoinType, 0)
|
2020-11-20 18:04:14 +00:00
|
|
|
hdPath := params.String()
|
2020-10-16 13:51:00 +00:00
|
|
|
require.Equal(t, "m/44'/60'/0'/0/0", hdPath)
|
|
|
|
require.Equal(t, hdPath, BIP44HDPath)
|
|
|
|
}
|