-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: remove unnecessary config.Seal()
#3786
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package app | ||
|
||
import sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
func init() { | ||
setCosmosSDKConfig() | ||
} | ||
|
||
func setCosmosSDKConfig() { | ||
config := sdk.GetConfig() | ||
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) | ||
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) | ||
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) | ||
config.Seal() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_setCosmosSDKConfig(t *testing.T) { | ||
config := sdk.GetConfig() | ||
assert.Equal(t, Bech32PrefixAccAddr, config.GetBech32AccountAddrPrefix()) | ||
assert.Equal(t, Bech32PrefixAccPub, config.GetBech32AccountPubPrefix()) | ||
assert.Equal(t, Bech32PrefixValAddr, config.GetBech32ValidatorAddrPrefix()) | ||
assert.Equal(t, Bech32PrefixValPub, config.GetBech32ValidatorPubPrefix()) | ||
assert.Equal(t, Bech32PrefixConsAddr, config.GetBech32ConsensusAddrPrefix()) | ||
assert.Equal(t, Bech32PrefixConsPub, config.GetBech32ConsensusPubPrefix()) | ||
Comment on lines
+10
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call The test func Test_setCosmosSDKConfig(t *testing.T) {
setCosmosSDKConfig() // Ensure this function is called
config := sdk.GetConfig()
assert.Equal(t, Bech32PrefixAccAddr, config.GetBech32AccountAddrPrefix())
assert.Equal(t, Bech32PrefixAccPub, config.GetBech32AccountPubPrefix())
assert.Equal(t, Bech32PrefixValAddr, config.GetBech32ValidatorAddrPrefix())
assert.Equal(t, Bech32PrefixValPub, config.GetBech32ValidatorPubPrefix())
assert.Equal(t, Bech32PrefixConsAddr, config.GetBech32ConsensusAddrPrefix())
assert.Equal(t, Bech32PrefixConsPub, config.GetBech32ConsensusPubPrefix())
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rootulp I also agree with this comment, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's invoked via |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider configuration flexibility.
The
setCosmosSDKConfig
function hardcodes Bech32 prefixes. Consider parameterizing these values to allow for greater flexibility and reusability in different environments or tests.