diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f37676af035..2088f6133f51 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -188,9 +188,9 @@ jobs: with: file: ./coverage.txt if: "env.GIT_DIFF != ''" - test-unit-proto-expected-to-fail: + test-unit-amino-might-fail: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: test-unit-proto - run: make test-unit-proto + - name: test-unit-amino + run: make test-unit-amino diff --git a/Makefile b/Makefile index 9121980a4de0..6bd2f0e9dce0 100644 --- a/Makefile +++ b/Makefile @@ -182,13 +182,13 @@ test-ledger-mock: test-ledger: test-ledger-mock @go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger' -test-unit: test-unit-amino # TODO switch test-unit-proto to be default here after proto Tx is fully tested +test-unit: test-unit-proto test-unit-proto: - @VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock test_proto' + @VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock' test-unit-amino: - @VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock' + @VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock test_amino' test-race: @VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION) diff --git a/go.sum b/go.sum index a974a53a772f..eea8e2ae65b5 100644 --- a/go.sum +++ b/go.sum @@ -197,6 +197,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= @@ -736,8 +737,6 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/simapp/params/amino.go b/simapp/params/amino.go index 871dba814e64..5c327b187352 100644 --- a/simapp/params/amino.go +++ b/simapp/params/amino.go @@ -1,6 +1,5 @@ -// +build !test_proto +// +build test_amino -// TODO switch to test_amino build flag once proto Tx's are ready package params import ( diff --git a/simapp/params/proto.go b/simapp/params/proto.go index 1de96d4a490d..066bdd7b7aae 100644 --- a/simapp/params/proto.go +++ b/simapp/params/proto.go @@ -1,6 +1,5 @@ -// +build test_proto +// +build !test_amino -// TODO switch to !test_amino build flag once proto Tx's are ready package params import ( diff --git a/x/auth/tx/builder_test.go b/x/auth/tx/builder_test.go index 8a1db1c985cf..0afd8dd85ad9 100644 --- a/x/auth/tx/builder_test.go +++ b/x/auth/tx/builder_test.go @@ -18,7 +18,7 @@ import ( func TestTxBuilder(t *testing.T) { _, pubkey, addr := testdata.KeyTestPubAddr() - marshaler := codec.NewHybridCodec(codec.New(), codectypes.NewInterfaceRegistry()) + marshaler := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) txBuilder := newBuilder(std.DefaultPublicKeyCodec{}) cdc := std.DefaultPublicKeyCodec{} @@ -230,3 +230,24 @@ func TestBuilderValidateBasic(t *testing.T) { err = txBuilder.ValidateBasic() require.Error(t, err) } + +func TestDefaultTxDecoderError(t *testing.T) { + registry := codectypes.NewInterfaceRegistry() + pubKeyCdc := std.DefaultPublicKeyCodec{} + encoder := DefaultTxEncoder() + decoder := DefaultTxDecoder(registry, pubKeyCdc) + + builder := newBuilder(pubKeyCdc) + err := builder.SetMsgs(testdata.NewTestMsg()) + require.NoError(t, err) + + txBz, err := encoder(builder.GetTx()) + require.NoError(t, err) + + _, err = decoder(txBz) + require.EqualError(t, err, "no registered implementations of type types.Msg: tx parse error") + + registry.RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{}) + _, err = decoder(txBz) + require.NoError(t, err) +} diff --git a/x/auth/tx/decoder.go b/x/auth/tx/decoder.go index e229c1f35b85..1ad8c73f1c84 100644 --- a/x/auth/tx/decoder.go +++ b/x/auth/tx/decoder.go @@ -5,11 +5,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - - "github.com/cosmos/cosmos-sdk/types/tx" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx" ) // DefaultTxDecoder returns a default protobuf TxDecoder using the provided Marshaler and PublicKeyCodec @@ -19,18 +18,18 @@ func DefaultTxDecoder(anyUnpacker types.AnyUnpacker, keyCodec cryptotypes.Public var raw tx.TxRaw err := cdc.UnmarshalBinaryBare(txBytes, &raw) if err != nil { - return nil, err + return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error()) } var theTx tx.Tx err = cdc.UnmarshalBinaryBare(txBytes, &theTx) if err != nil { - return nil, err + return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error()) } pks, err := extractPubKeys(theTx, keyCodec) if err != nil { - return nil, err + return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error()) } return &builder{ @@ -50,12 +49,12 @@ func DefaultJSONTxDecoder(anyUnpacker types.AnyUnpacker, keyCodec cryptotypes.Pu var theTx tx.Tx err := cdc.UnmarshalJSON(txBytes, &theTx) if err != nil { - return nil, err + return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error()) } pks, err := extractPubKeys(theTx, keyCodec) if err != nil { - return nil, err + return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error()) } return &builder{ diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 0e587ce2f1d6..f3aa03d1029f 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -24,6 +24,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgWithdrawDelegatorReward{}, &MsgWithdrawValidatorCommission{}, &MsgSetWithdrawAddress{}, + &MsgFundCommunityPool{}, ) registry.RegisterImplementations( (*govtypes.Content)(nil),