Skip to content

Commit

Permalink
Merge bump50
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed Feb 21, 2024
2 parents 56ee192 + 2cc0f1b commit b8f4fc3
Show file tree
Hide file tree
Showing 42 changed files with 2,967 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .github/pr_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
- x/collection/**/*
"C:x/foundation":
- x/foundation/**/*
"C:x/stakingplus":
- x/stakingplus/**/*
33 changes: 32 additions & 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 Expand Up @@ -323,3 +323,34 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/foundation/

test-x-stakingplus:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: x/stakingplus/go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
x/stakingplus/**/*.go
x/stakingplus/go.mod
x/stakingplus/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd x/stakingplus
go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb_build' ./...
- name: sonarcloud
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 }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/stakingplus/
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased](https://github.com/Finschia/finschia-sdk/compare/v0.48.0...HEAD)

### Features
* (x/staking) [\#1214](https://github.com/Finschia/finschia-sdk/pull/1214) update x/stakingplus to use Finschia/cosmos-sdk
* (x/foundation) [\#1198](https://github.com/Finschia/finschia-sdk/pull/1198) update x/foundation to use Finschia/cosmos-sdk
* (all) [\#1205](https://github.com/Finschia/finschia-sdk/pull/1205) delegate native logics to Finschia/cosmos-sdk
* (consensus) [\#1178](https://github.com/Finschia/finschia-sdk/pull/1178) change the consensus from Ostracon to Tendermint v0.34.24
Expand All @@ -52,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
1 change: 1 addition & 0 deletions go.work.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ use (
./tests
./x/collection
./x/foundation
./x/stakingplus
)
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
1 change: 1 addition & 0 deletions scripts/mockgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ $mockgen_cmd -source=x/gov/testutil/expected_keepers.go -package testutil -desti
$mockgen_cmd -source=x/staking/types/expected_keepers.go -package testutil -destination x/staking/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/auth/vesting/types/expected_keepers.go -package testutil -destination x/auth/vesting/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/foundation/expected_keepers.go -package testutil -destination x/foundation/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/stakingplus/expected_keepers.go -package testutil -destination x/stakingplus/testutil/expected_keepers_mocks.go
4 changes: 2 additions & 2 deletions scripts/protocgen-pulsar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ echo "Cleaning API directory"
echo "Generating API module"
(cd proto; buf generate --template buf.gen.pulsar.yaml)

echo "Generate Pulsar Test Data"
(cd testutil/testdata; buf generate --template buf.gen.pulsar.yaml)
# echo "Generate Pulsar Test Data"
# (cd testutil/testdata; buf generate --template buf.gen.pulsar.yaml)
2 changes: 1 addition & 1 deletion simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import (
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

collectionmodulev1 "github.com/Finschia/finschia-sdk/api/lbm/collection/module/v1"
Expand All @@ -79,6 +78,7 @@ import (
_ "github.com/Finschia/finschia-sdk/x/collection/module" // import for side-effects
"github.com/Finschia/finschia-sdk/x/foundation"
_ "github.com/Finschia/finschia-sdk/x/foundation/module" // import for side-effects
_ "github.com/Finschia/finschia-sdk/x/stakingplus/module" // import for side-effects
)

var (
Expand Down
6 changes: 3 additions & 3 deletions simapp/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"

collectionmodule "github.com/Finschia/finschia-sdk/x/collection/module"
foundationmodule "github.com/Finschia/finschia-sdk/x/foundation/module"
stakingplusmodule "github.com/Finschia/finschia-sdk/x/stakingplus/module"
)

func TestSimAppExportAndBlockedAddrs(t *testing.T) {
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestRunMigrations(t *testing.T) {
"bank": 1,
"auth": auth.AppModule{}.ConsensusVersion(),
"authz": authzmodule.AppModule{}.ConsensusVersion(),
"staking": staking.AppModule{}.ConsensusVersion(),
"staking": stakingplusmodule.AppModule{}.ConsensusVersion(),
"mint": mint.AppModule{}.ConsensusVersion(),
"distribution": distribution.AppModule{}.ConsensusVersion(),
"slashing": slashing.AppModule{}.ConsensusVersion(),
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"bank": bank.AppModule{}.ConsensusVersion(),
"auth": auth.AppModule{}.ConsensusVersion(),
"authz": authzmodule.AppModule{}.ConsensusVersion(),
"staking": staking.AppModule{}.ConsensusVersion(),
"staking": stakingplusmodule.AppModule{}.ConsensusVersion(),
"mint": mint.AppModule{}.ConsensusVersion(),
"distribution": distribution.AppModule{}.ConsensusVersion(),
"slashing": slashing.AppModule{}.ConsensusVersion(),
Expand Down
2 changes: 2 additions & 0 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
github.com/Finschia/finschia-sdk/x/collection v0.0.0-00010101000000-000000000000
github.com/Finschia/finschia-sdk/x/foundation v0.0.0-00010101000000-000000000000
github.com/cometbft/cometbft v0.38.3
github.com/Finschia/finschia-sdk/x/stakingplus v0.0.0-00010101000000-000000000000
github.com/cosmos/cosmos-db v1.0.0
// this version is not used as it is always replaced by the latest Cosmos SDK version
github.com/cosmos/cosmos-sdk v0.50.3
Expand Down Expand Up @@ -219,6 +220,7 @@ replace (
github.com/Finschia/finschia-sdk/api => ../api
github.com/Finschia/finschia-sdk/x/collection => ../x/collection
github.com/Finschia/finschia-sdk/x/foundation => ../x/foundation
github.com/Finschia/finschia-sdk/x/stakingplus => ../x/stakingplus
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
Expand Down
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
Loading

0 comments on commit b8f4fc3

Please sign in to comment.