diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61cab20ca7..f3139c95f9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -185,7 +185,7 @@ jobs: name: "${{ github.sha }}-e2e-coverage" continue-on-error: true - name: sonarcloud - if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }} + if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null}} uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.golangci.yml b/.golangci.yml index 37d5c4b41d..8ea09b0436 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -52,8 +52,7 @@ issues: - text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out linters: - staticcheck - - path: "client/cli" # TODO(@0Tech): remove after foundation exec proposal removed - text: "SA1019: govcli.FlagDescription is deprecated" + - text: "SA1019: govcli.FlagDescription is deprecated" # TODO(@0Tech): remove after foundation exec proposal removed linters: - staticcheck - text: "leading space" diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b7ed6c4ee..3ef03d29d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/crisis) [#1167](https://github.com/Finschia/finschia-sdk/pull/1167) Use `CacheContext()` in `AssertInvariants()` * (chore) [\#1168](https://github.com/Finschia/finschia-sdk/pull/1168) Replace `ExactArgs(0)` with `NoArgs()` in `x/upgrade` module * (server) [\#1175](https://github.com/Finschia/finschia-sdk/pull/1175) Use go embed for swagger +* (e2e) [\#1237](https://github.com/Finschia/finschia-sdk/pull/1237) Check tx result on x/foundation e2e test ### Bug Fixes * chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue diff --git a/scripts/go-lint-all.bash b/scripts/go-lint-all.bash index 8850c65cd1..decaaa8287 100755 --- a/scripts/go-lint-all.bash +++ b/scripts/go-lint-all.bash @@ -31,7 +31,7 @@ else for f in $(dirname $(echo "$GIT_DIFF" | tr -d "'") | uniq); do echo "linting $f [$(date -Iseconds -u)]" && cd $f && - golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" && + golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" cd $REPO_ROOT done -fi \ No newline at end of file +fi diff --git a/tests/e2e/foundation/grpc.go b/tests/e2e/foundation/grpc.go index 95aa701f65..73c0ece707 100644 --- a/tests/e2e/foundation/grpc.go +++ b/tests/e2e/foundation/grpc.go @@ -3,7 +3,7 @@ package foundation import ( "fmt" - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" "cosmossdk.io/math" diff --git a/tests/e2e/foundation/query.go b/tests/e2e/foundation/query.go index a31f9ffe8c..713bc945c9 100644 --- a/tests/e2e/foundation/query.go +++ b/tests/e2e/foundation/query.go @@ -4,7 +4,7 @@ import ( "fmt" cmtcli "github.com/cometbft/cometbft/libs/cli" - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" "cosmossdk.io/math" diff --git a/tests/e2e/foundation/suite.go b/tests/e2e/foundation/suite.go index 9d65a7d9bb..c1a1ffca98 100644 --- a/tests/e2e/foundation/suite.go +++ b/tests/e2e/foundation/suite.go @@ -1,10 +1,12 @@ package foundation import ( + "encoding/hex" "encoding/json" "fmt" "time" + "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/suite" "cosmossdk.io/core/address" @@ -135,23 +137,13 @@ func (s *E2ETestSuite) SetupSuite() { s.createAccount("leavingmember", leavingMemberMnemonic) s.createAccount("permanentmember", permanentMemberMnemonic) - s.submitProposal(&foundation.MsgWithdrawFromTreasury{ + s.proposalID = s.submitProposal(&foundation.MsgWithdrawFromTreasury{ Authority: s.bytesToString(s.authority), To: s.bytesToString(s.stranger), Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(123))), }, false) - s.proposalID = 1 s.vote(s.proposalID, []sdk.AccAddress{s.leavingMember, s.permanentMember}) - // submit another two proposals without votes - for range make([]struct{}, 2) { - s.submitProposal(&foundation.MsgWithdrawFromTreasury{ - Authority: s.bytesToString(s.authority), - To: s.bytesToString(s.stranger), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(123))), - }, false) - } - s.setupHeight, err = s.network.LatestHeight() s.Require().NoError(err) } @@ -168,7 +160,7 @@ func (s *E2ETestSuite) bytesToString(addr sdk.AccAddress) string { } // submit a proposal -func (s *E2ETestSuite) submitProposal(msg sdk.Msg, try bool) { +func (s *E2ETestSuite) submitProposal(msg sdk.Msg, try bool) uint64 { val := s.network.Validators[0] proposers := []string{s.bytesToString(s.permanentMember)} @@ -190,7 +182,18 @@ func (s *E2ETestSuite) submitProposal(msg sdk.Msg, try bool) { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out.String()) s.Require().Zero(res.Code, out.String()) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) + + dataBytes, err := hex.DecodeString(res.Data) + s.Require().NoError(err) + var data sdk.TxMsgData + s.Require().NoError(proto.Unmarshal(dataBytes, &data)) + var msgResp foundation.MsgSubmitProposalResponse + s.Require().NoError(proto.Unmarshal(data.MsgResponses[0].Value, &msgResp), data.MsgResponses[0]) + + return msgResp.ProposalId } func (s *E2ETestSuite) vote(proposalID uint64, voters []sdk.AccAddress) { @@ -209,9 +212,11 @@ func (s *E2ETestSuite) vote(proposalID uint64, voters []sdk.AccAddress) { var res sdk.TxResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out.String()) s.Require().Zero(res.Code, out.String()) - } - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) + } } func (s *E2ETestSuite) msgToString(msg sdk.Msg) string { @@ -260,5 +265,7 @@ func (s *E2ETestSuite) createAccount(uid, mnemonic string) { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out.String()) s.Require().Zero(res.Code, out.String()) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) } diff --git a/tests/e2e/foundation/tx.go b/tests/e2e/foundation/tx.go index 4a90845de8..616f7b39be 100644 --- a/tests/e2e/foundation/tx.go +++ b/tests/e2e/foundation/tx.go @@ -61,7 +61,9 @@ func (s *E2ETestSuite) TestNewTxCmdFundTreasury() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out) s.Require().Zero(res.Code, out) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) }) } } @@ -276,7 +278,9 @@ func (s *E2ETestSuite) TestNewTxCmdSubmitProposal() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out) s.Require().Zero(res.Code, out) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) }) } } @@ -290,7 +294,12 @@ func (s *E2ETestSuite) TestNewTxCmdWithdrawProposal() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10)))), } - proposalID := 2 + proposalID := s.submitProposal(&foundation.MsgWithdrawFromTreasury{ + Authority: s.bytesToString(s.authority), + To: s.bytesToString(s.stranger), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(123))), + }, false) + testCases := map[string]struct { args []string valid bool @@ -328,7 +337,9 @@ func (s *E2ETestSuite) TestNewTxCmdWithdrawProposal() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out) s.Require().Zero(res.Code, out) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) }) } } @@ -342,7 +353,12 @@ func (s *E2ETestSuite) TestNewTxCmdVote() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10)))), } - proposalID := 3 + proposalID := s.submitProposal(&foundation.MsgWithdrawFromTreasury{ + Authority: s.bytesToString(s.authority), + To: s.bytesToString(s.stranger), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(123))), + }, false) + testCases := map[string]struct { args []string valid bool @@ -384,7 +400,9 @@ func (s *E2ETestSuite) TestNewTxCmdVote() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out) s.Require().Zero(res.Code, out) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) }) } } @@ -435,7 +453,9 @@ func (s *E2ETestSuite) TestNewTxCmdExec() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out) s.Require().Zero(res.Code, out) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) }) } } @@ -547,7 +567,9 @@ func (s *E2ETestSuite) TestNewTxCmdLeaveFoundation() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res), out) s.Require().Zero(res.Code, out) - s.Require().NoError(s.network.WaitForNextBlock()) + res, err = clitestutil.GetTxResponse(s.network, val.ClientCtx, res.TxHash) + s.Require().NoError(err) + s.Require().Zero(res.Code, res.RawLog) }) } } diff --git a/tests/go.mod b/tests/go.mod index 895f09b3cf..970cfada0d 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.2 // indirect cosmossdk.io/core v0.11.0 cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/errors v1.0.0 + cosmossdk.io/errors v1.0.0 // indirect cosmossdk.io/log v1.2.1 // indirect cosmossdk.io/math v1.2.0 cosmossdk.io/store v1.0.1 // indirect @@ -20,7 +20,7 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect // this version is not used as it is always replaced by the latest Cosmos SDK version github.com/cosmos/cosmos-sdk v0.51.0 - github.com/cosmos/gogoproto v1.4.11 // indirect + github.com/cosmos/gogoproto v1.4.11 github.com/golang/mock v1.6.0 // indirect github.com/spf13/cobra v1.7.0 // indirect github.com/stretchr/testify v1.8.4 @@ -35,7 +35,6 @@ require ( github.com/Finschia/finschia-sdk/x/foundation v0.0.0-00010101000000-000000000000 github.com/Finschia/finschia-sdk/x/stakingplus v0.0.0-00010101000000-000000000000 github.com/cosmos/go-bip39 v1.0.0 - github.com/gogo/protobuf v1.3.2 ) require ( @@ -93,6 +92,7 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect diff --git a/x/foundation/authz.go b/x/foundation/authz.go index cf29bbabdb..bb0e1bd619 100644 --- a/x/foundation/authz.go +++ b/x/foundation/authz.go @@ -1,7 +1,7 @@ package foundation import ( - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/foundation/events.go b/x/foundation/events.go index 42032f1af0..5cd21d8b3e 100644 --- a/x/foundation/events.go +++ b/x/foundation/events.go @@ -1,7 +1,7 @@ package foundation import ( - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/foundation/foundation.go b/x/foundation/foundation.go index 5fe3e68945..1a9c30e609 100644 --- a/x/foundation/foundation.go +++ b/x/foundation/foundation.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" "cosmossdk.io/core/address" errorsmod "cosmossdk.io/errors" diff --git a/x/foundation/genesis.go b/x/foundation/genesis.go index 8cfb5e46b1..195d2f8525 100644 --- a/x/foundation/genesis.go +++ b/x/foundation/genesis.go @@ -1,7 +1,7 @@ package foundation import ( - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" "cosmossdk.io/core/address" "cosmossdk.io/math" diff --git a/x/foundation/go.mod b/x/foundation/go.mod index 94d6ef675a..5917c1c5bc 100644 --- a/x/foundation/go.mod +++ b/x/foundation/go.mod @@ -14,7 +14,6 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.50.2 github.com/cosmos/gogoproto v1.4.11 - github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -73,6 +72,7 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect diff --git a/x/foundation/keeper/internal/grpc_query.go b/x/foundation/keeper/internal/grpc_query.go index deef12f9b9..74d84e2955 100644 --- a/x/foundation/keeper/internal/grpc_query.go +++ b/x/foundation/keeper/internal/grpc_query.go @@ -3,7 +3,7 @@ package internal import ( "context" - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/foundation/msgs.go b/x/foundation/msgs.go index 74ff7259d6..44ce8bc7ed 100644 --- a/x/foundation/msgs.go +++ b/x/foundation/msgs.go @@ -1,7 +1,7 @@ package foundation import ( - "github.com/gogo/protobuf/proto" + "github.com/cosmos/gogoproto/proto" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types"