x/bank: convert query CLI commands to use gRPC query client (#6367)
* Convert x/bank query cli methods to use gRPC query client * WIP on x/bank cli query migration * lint * Fix integration tests * Remove Println in favor of updated PrintOutput * Add PrintOutput tests Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze
parent
1c8249e26d
commit
257354dbff
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
package testdata
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/tendermint/go-amino"
|
||||
)
|
||||
|
||||
func NewTestInterfaceRegistry() types.InterfaceRegistry {
|
||||
registry := types.NewInterfaceRegistry()
|
||||
registry.RegisterInterface("Animal", (*Animal)(nil))
|
||||
registry.RegisterImplementations(
|
||||
(*Animal)(nil),
|
||||
&Dog{},
|
||||
&Cat{},
|
||||
)
|
||||
registry.RegisterImplementations(
|
||||
(*HasAnimalI)(nil),
|
||||
&HasAnimal{},
|
||||
)
|
||||
registry.RegisterImplementations(
|
||||
(*HasHasAnimalI)(nil),
|
||||
&HasHasAnimal{},
|
||||
)
|
||||
return registry
|
||||
}
|
||||
|
||||
func NewTestAmino() *amino.Codec {
|
||||
cdc := amino.NewCodec()
|
||||
cdc.RegisterInterface((*Animal)(nil), nil)
|
||||
cdc.RegisterConcrete(&Dog{}, "testdata/Dog", nil)
|
||||
cdc.RegisterConcrete(&Cat{}, "testdata/Cat", nil)
|
||||
|
||||
cdc.RegisterInterface((*HasAnimalI)(nil), nil)
|
||||
cdc.RegisterConcrete(&HasAnimal{}, "testdata/HasAnimal", nil)
|
||||
|
||||
cdc.RegisterInterface((*HasHasAnimalI)(nil), nil)
|
||||
cdc.RegisterConcrete(&HasHasAnimal{}, "testdata/HasHasAnimal", nil)
|
||||
|
||||
return cdc
|
||||
}
|
||||
@@ -26,7 +26,7 @@ type Suite struct {
|
||||
func (s *Suite) SetupTest() {
|
||||
s.cdc = amino.NewCodec()
|
||||
s.cdc.RegisterInterface((*testdata.Animal)(nil), nil)
|
||||
s.cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dob", nil)
|
||||
s.cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog", nil)
|
||||
|
||||
s.spot = &testdata.Dog{Size_: "small", Name: "Spot"}
|
||||
s.a = TypeWithInterface{Animal: s.spot}
|
||||
|
||||
@@ -13,27 +13,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec/testdata"
|
||||
)
|
||||
|
||||
func NewTestInterfaceRegistry() types.InterfaceRegistry {
|
||||
registry := types.NewInterfaceRegistry()
|
||||
registry.RegisterInterface("Animal", (*testdata.Animal)(nil))
|
||||
registry.RegisterImplementations(
|
||||
(*testdata.Animal)(nil),
|
||||
&testdata.Dog{},
|
||||
&testdata.Cat{},
|
||||
)
|
||||
registry.RegisterImplementations(
|
||||
(*testdata.HasAnimalI)(nil),
|
||||
&testdata.HasAnimal{},
|
||||
)
|
||||
registry.RegisterImplementations(
|
||||
(*testdata.HasHasAnimalI)(nil),
|
||||
&testdata.HasHasAnimal{},
|
||||
)
|
||||
return registry
|
||||
}
|
||||
|
||||
func TestPackUnpack(t *testing.T) {
|
||||
registry := NewTestInterfaceRegistry()
|
||||
registry := testdata.NewTestInterfaceRegistry()
|
||||
|
||||
spot := &testdata.Dog{Name: "Spot"}
|
||||
any := types.Any{}
|
||||
@@ -81,7 +62,7 @@ func TestRegister(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnpackInterfaces(t *testing.T) {
|
||||
registry := NewTestInterfaceRegistry()
|
||||
registry := testdata.NewTestInterfaceRegistry()
|
||||
|
||||
spot := &testdata.Dog{Name: "Spot"}
|
||||
any, err := types.NewAnyWithValue(spot)
|
||||
@@ -105,7 +86,7 @@ func TestUnpackInterfaces(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNested(t *testing.T) {
|
||||
registry := NewTestInterfaceRegistry()
|
||||
registry := testdata.NewTestInterfaceRegistry()
|
||||
|
||||
spot := &testdata.Dog{Name: "Spot"}
|
||||
any, err := types.NewAnyWithValue(spot)
|
||||
@@ -145,7 +126,7 @@ func TestAny_ProtoJSON(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"@type\":\"/cosmos_sdk.codec.v1.Dog\",\"name\":\"Spot\"}", json)
|
||||
|
||||
registry := NewTestInterfaceRegistry()
|
||||
registry := testdata.NewTestInterfaceRegistry()
|
||||
jum := &jsonpb.Unmarshaler{}
|
||||
var any2 types.Any
|
||||
err = jum.Unmarshal(strings.NewReader(json), &any2)
|
||||
|
||||
Reference in New Issue
Block a user