* WIP: using encoding config * Make it compile, test fails * test should be okay * Make tests pass * Add comments * Convert more tests * Make TestAnteHandlerSigErrors work * Make first 2 tests pass * TestAnteHandlerAccountNumbers * Use table tests * Remove print * Use test table * TestAnteHandlerSigErrors * TestAnteHandlerAccountNumbers * TestAnteHandlerAccountNumbers * Refactor TestAccount * Refactor getSignBytes * TestAnteHandlerAccountNumbersAtBlockHeightZero * TestAnteHandlerSequences * TestAnteHandlerFees * TestAnteHandlerMultiSigner * TestAnteHandlerBadSignBytes * TestAnteHandlerSetPubKey * TestAnteHandlerSigLimitExceeded * TestCustomSignatureVerificationGasConsumer * TestAnteHandlerReCheck * Make all tests pass * Refactor a little bit more * Fee test * SetupTest * All tests pass * Refactor to RunTestCase * Don't use StdFee * Revert some little stuff * Finish up last couple of test cases * Less verbose * s/TxGenerator/TxConfig * Add comments * Indent * Move KeyTestPubAddr to testdata * Move testdata to /testutil * Revert to use signature: nil step in signing * Add comments Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package testdata
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
|
)
|
|
|
|
type TestServiceImpl struct{}
|
|
|
|
func (e TestServiceImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAnyResponse, error) {
|
|
animal, ok := request.AnyAnimal.GetCachedValue().(Animal)
|
|
if !ok {
|
|
return nil, fmt.Errorf("expected Animal")
|
|
}
|
|
|
|
any, err := types.NewAnyWithValue(animal.(proto.Message))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &TestAnyResponse{HasAnimal: &HasAnimal{
|
|
Animal: any,
|
|
X: 10,
|
|
}}, nil
|
|
}
|
|
|
|
func (e TestServiceImpl) Echo(_ context.Context, req *EchoRequest) (*EchoResponse, error) {
|
|
return &EchoResponse{Message: req.Message}, nil
|
|
}
|
|
|
|
func (e TestServiceImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHelloResponse, error) {
|
|
greeting := fmt.Sprintf("Hello %s!", request.Name)
|
|
return &SayHelloResponse{Greeting: greeting}, nil
|
|
}
|
|
|
|
var _ TestServiceServer = TestServiceImpl{}
|
|
|
|
var _ types.UnpackInterfacesMessage = &TestAnyRequest{}
|
|
|
|
func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
|
var animal Animal
|
|
return unpacker.UnpackAny(m.AnyAnimal, &animal)
|
|
}
|
|
|
|
var _ types.UnpackInterfacesMessage = &TestAnyResponse{}
|
|
|
|
func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error {
|
|
return m.HasAnimal.UnpackInterfaces(unpacker)
|
|
}
|