Skip to content

Commit

Permalink
Merge bumpup50
Browse files Browse the repository at this point in the history
  • Loading branch information
ulbqb committed Feb 16, 2024
2 parents a704727 + 35e6c72 commit 72ad428
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/go-lint-all.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
fi
2 changes: 1 addition & 1 deletion tests/e2e/foundation/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package foundation
import (
"fmt"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/math"

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/foundation/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
39 changes: 23 additions & 16 deletions tests/e2e/foundation/suite.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)}
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
38 changes: 30 additions & 8 deletions tests/e2e/foundation/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
Expand Down Expand Up @@ -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)
})
}
}
Expand All @@ -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
Expand Down Expand Up @@ -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)
})
}
}
Expand All @@ -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
Expand Down Expand Up @@ -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)
})
}
}
Expand Down Expand Up @@ -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)
})
}
}
Expand Down Expand Up @@ -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)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/foundation/authz.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion x/foundation/events.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion x/foundation/foundation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion x/foundation/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package foundation

import (
"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/core/address"
"cosmossdk.io/math"
Expand Down
2 changes: 1 addition & 1 deletion x/foundation/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/foundation/keeper/internal/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion x/foundation/msgs.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 72ad428

Please sign in to comment.