-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: remove some deps from testutil/network (#20843)
- Loading branch information
1 parent
59f4aa3
commit f82bb76
Showing
33 changed files
with
119 additions
and
204 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,74 @@ | ||
package codec_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" | ||
"cosmossdk.io/core/address" | ||
"cosmossdk.io/depinject" | ||
"cosmossdk.io/log" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
) | ||
|
||
var _ address.Codec = (*customAddressCodec)(nil) | ||
|
||
type customAddressCodec struct{} | ||
|
||
func (c customAddressCodec) StringToBytes(text string) ([]byte, error) { | ||
return []byte(text), nil | ||
} | ||
|
||
func (c customAddressCodec) BytesToString(bz []byte) (string, error) { | ||
return string(bz), nil | ||
} | ||
|
||
func AuthConfig() *authmodulev1.Module { return &authmodulev1.Module{Bech32Prefix: "cosmos"} } | ||
|
||
func TestProvideAddressCodec(t *testing.T) { | ||
var addrCodec address.Codec | ||
var valAddressCodec address.ValidatorAddressCodec | ||
var consAddressCodec address.ConsensusAddressCodec | ||
|
||
err := depinject.Inject( | ||
depinject.Provide( | ||
AuthConfig, | ||
codec.ProvideAddressCodec, | ||
), | ||
&addrCodec, &valAddressCodec, &consAddressCodec) | ||
require.NoError(t, err) | ||
require.NotNil(t, addrCodec) | ||
_, ok := addrCodec.(customAddressCodec) | ||
require.False(t, ok) | ||
require.NotNil(t, valAddressCodec) | ||
_, ok = valAddressCodec.(customAddressCodec) | ||
require.False(t, ok) | ||
require.NotNil(t, consAddressCodec) | ||
_, ok = consAddressCodec.(customAddressCodec) | ||
require.False(t, ok) | ||
|
||
// Set the address codec to the custom one | ||
err = depinject.Inject( | ||
depinject.Configs( | ||
depinject.Provide(AuthConfig, codec.ProvideAddressCodec), | ||
depinject.Supply( | ||
log.NewNopLogger(), | ||
func() address.Codec { return customAddressCodec{} }, | ||
func() address.ValidatorAddressCodec { return customAddressCodec{} }, | ||
func() address.ConsensusAddressCodec { return customAddressCodec{} }, | ||
), | ||
), | ||
&addrCodec, &valAddressCodec, &consAddressCodec) | ||
require.NoError(t, err) | ||
require.NotNil(t, addrCodec) | ||
_, ok = addrCodec.(customAddressCodec) | ||
require.True(t, ok) | ||
require.NotNil(t, valAddressCodec) | ||
_, ok = valAddressCodec.(customAddressCodec) | ||
require.True(t, ok) | ||
require.NotNil(t, consAddressCodec) | ||
_, ok = consAddressCodec.(customAddressCodec) | ||
require.True(t, ok) | ||
} |
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
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
Oops, something went wrong.