-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client/keys/parse: honor config changes (#6340)
`keys parse` uses the global configuration before before client applications have had a chance to apply their settings. This change adds a `GetSealedConfig()` helper that waits for the config to be sealed before returning it. Fixes: #5091 Origin: 4e328d7 Author: Adam Bozanich <adam.boz@gmail.com> Reviewed-by: Alessio Treglia <alessio@tendermint.com>
- Loading branch information
Alessio Treglia
authored
Jun 9, 2020
1 parent
1c917e2
commit dd6f8c8
Showing
4 changed files
with
128 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package types_test | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func TestConfig_SetCoinType(t *testing.T) { | ||
config := sdk.NewConfig() | ||
config.SetCoinType(1) | ||
require.Equal(t, uint32(1), config.GetCoinType()) | ||
config.SetCoinType(99) | ||
require.Equal(t, uint32(99), config.GetCoinType()) | ||
|
||
config.Seal() | ||
require.Panics(t, func() { config.SetCoinType(99) }) | ||
} | ||
|
||
func TestConfig_SetTxEncoder(t *testing.T) { | ||
mockErr := errors.New("test") | ||
config := sdk.NewConfig() | ||
require.Nil(t, config.GetTxEncoder()) | ||
encFunc := sdk.TxEncoder(func(tx sdk.Tx) ([]byte, error) { return nil, nil }) | ||
config.SetTxEncoder(encFunc) | ||
_, err := config.GetTxEncoder()(sdk.Tx(nil)) | ||
require.Error(t, mockErr, err) | ||
|
||
config.Seal() | ||
require.Panics(t, func() { config.SetTxEncoder(encFunc) }) | ||
} | ||
|
||
func TestConfig_SetFullFundraiserPath(t *testing.T) { | ||
config := sdk.NewConfig() | ||
config.SetFullFundraiserPath("test/path") | ||
require.Equal(t, "test/path", config.GetFullFundraiserPath()) | ||
|
||
config.SetFullFundraiserPath("test/poth") | ||
require.Equal(t, "test/poth", config.GetFullFundraiserPath()) | ||
|
||
config.Seal() | ||
require.Panics(t, func() { config.SetFullFundraiserPath("x/test/path") }) | ||
} | ||
|
||
func TestKeyringServiceName(t *testing.T) { | ||
require.Equal(t, sdk.DefaultKeyringServiceName, sdk.KeyringServiceName()) | ||
} |