refactor(test)!: refactor simapp.Setup function (#9938)

<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

ref: #8961 

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->
Following up on [#9697](https://github.com/cosmos/cosmos-sdk/pull/9697#pullrequestreview-727295733), this PR is the first step for the #8961.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [x] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
This commit is contained in:
MD Aleem
2021-08-17 00:52:06 +00:00
committed by GitHub
parent 30228653ba
commit 23e864bc98
87 changed files with 264 additions and 242 deletions
+5 -4
View File
@@ -2,6 +2,7 @@ package query_test
import (
"fmt"
"testing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
@@ -15,7 +16,7 @@ import (
var addr1 = sdk.AccAddress([]byte("addr1"))
func (s *paginationTestSuite) TestFilteredPaginations() {
app, ctx, appCodec := setupTest()
app, ctx, appCodec := setupTest(s.T())
var balances sdk.Coins
for i := 0; i < numBalances; i++ {
@@ -90,7 +91,7 @@ func (s *paginationTestSuite) TestFilteredPaginations() {
}
func (s *paginationTestSuite) TestReverseFilteredPaginations() {
app, ctx, appCodec := setupTest()
app, ctx, appCodec := setupTest(s.T())
var balances sdk.Coins
for i := 0; i < numBalances; i++ {
@@ -170,8 +171,8 @@ func (s *paginationTestSuite) TestReverseFilteredPaginations() {
}
func ExampleFilteredPaginate() {
app, ctx, _ := setupTest()
func ExampleFilteredPaginate(t *testing.T) {
app, ctx, _ := setupTest(t)
var balances sdk.Coins
for i := 0; i < numBalances; i++ {
+6 -6
View File
@@ -61,7 +61,7 @@ func (s *paginationTestSuite) TestParsePagination() {
}
func (s *paginationTestSuite) TestPagination() {
app, ctx, _ := setupTest()
app, ctx, _ := setupTest(s.T())
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, app.BankKeeper)
queryClient := types.NewQueryClient(queryHelper)
@@ -170,7 +170,7 @@ func (s *paginationTestSuite) TestPagination() {
}
func (s *paginationTestSuite) TestReversePagination() {
app, ctx, _ := setupTest()
app, ctx, _ := setupTest(s.T())
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, app.BankKeeper)
queryClient := types.NewQueryClient(queryHelper)
@@ -293,8 +293,8 @@ func (s *paginationTestSuite) TestReversePagination() {
s.Require().Nil(res.Pagination.NextKey)
}
func ExamplePaginate() {
app, ctx, _ := setupTest()
func ExamplePaginate(t *testing.T) {
app, ctx, _ := setupTest(t)
var balances sdk.Coins
@@ -335,8 +335,8 @@ func ExamplePaginate() {
// balances:<denom:"foo0denom" amount:"100" > pagination:<next_key:"foo1denom" total:2 >
}
func setupTest() (*simapp.SimApp, sdk.Context, codec.Codec) {
app := simapp.Setup(false)
func setupTest(t *testing.T) (*simapp.SimApp, sdk.Context, codec.Codec) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1})
appCodec := app.AppCodec()