Skip to content

Commit

Permalink
feat: add x/auth app wiring integration tests (#12329)
Browse files Browse the repository at this point in the history
## Description
ref: #12302 


---

### 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...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] 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)
  • Loading branch information
likhita-809 committed Jun 23, 2022
1 parent 69c9e3e commit 77c764c
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 7 deletions.
5 changes: 4 additions & 1 deletion x/auth/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import (
"testing"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg.NumValidators = 2
suite.Run(t, NewIntegrationTestSuite(cfg))
}
3 changes: 3 additions & 0 deletions x/auth/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,10 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
require.Equal(sdk.NewCoins(val0Coin, val1Coin), queryRes.Balances)
}

// TODO to re-enable in #12274
func (s *IntegrationTestSuite) TestAuxSigner() {
s.T().Skip()

require := s.Require()
val := s.network.Validators[0]
val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10))
Expand Down
4 changes: 2 additions & 2 deletions x/auth/migrations/legacytx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
txtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil/tx"
)

func testCodec() *codec.LegacyAmino {
Expand All @@ -24,5 +24,5 @@ func testCodec() *codec.LegacyAmino {
func TestStdTxConfig(t *testing.T) {
cdc := testCodec()
txGen := legacytx.StdTxConfig{Cdc: cdc}
suite.Run(t, testutil.NewTxConfigTestSuite(txGen))
suite.Run(t, txtestutil.NewTxConfigTestSuite(txGen))
}
5 changes: 5 additions & 0 deletions x/auth/spec/08_app_wiring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# App Wiring

The minimal app-wiring configuration for `x/auth` is as follows:

+++ https://github.com/cosmos/cosmos-sdk/blob/188e1ec30dffaad020cd4a72747e3da49d714a78/x/auth/testutil/app.yaml
1 change: 1 addition & 0 deletions x/auth/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ This module is used in the Cosmos Hub.
* [REST](07_client.md#rest)
* **[Vesting](07_client.md#vesting)**
* [CLI](07_client.md#vesting#cli)
8. **[App Wiring](08_app_wiring.md)**
51 changes: 51 additions & 0 deletions x/auth/testutil/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
modules:
- name: runtime
config:
"@type": cosmos.app.runtime.v1alpha1.Module

app_name: AuthApp

begin_blockers: [staking, auth, bank, genutil, feegrant, params, vesting]
end_blockers: [staking, auth, bank, genutil, feegrant, params, vesting]
init_genesis: [auth, bank, staking, genutil, feegrant, params, vesting]

- name: auth
config:
"@type": cosmos.auth.module.v1.Module
bech32_prefix: cosmos
module_account_permissions:
- account: fee_collector
- account: mint
permissions: [minter]
- account: bonded_tokens_pool
permissions: [burner, staking]
- account: not_bonded_tokens_pool
permissions: [burner, staking]

- name: bank
config:
"@type": cosmos.bank.module.v1.Module

- name: params
config:
"@type": cosmos.params.module.v1.Module

- name: tx
config:
"@type": cosmos.tx.module.v1.Module

- name: staking
config:
"@type": cosmos.staking.module.v1.Module

- name: genutil
config:
"@type": cosmos.genutil.module.v1.Module

- name: feegrant
config:
"@type": cosmos.feegrant.module.v1.Module

- name: vesting
config:
"@type": cosmos.vesting.module.v1.Module
22 changes: 22 additions & 0 deletions x/auth/testutil/app_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package testutil

import (
_ "embed"

_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
_ "github.com/cosmos/cosmos-sdk/x/auth/vesting"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/feegrant/module"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/gov"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"

"cosmossdk.io/core/appconfig"
)

//go:embed app.yaml
var appConfig []byte

var AppConfig = appconfig.LoadYAML(appConfig)
2 changes: 1 addition & 1 deletion x/auth/testutil/suite.go → x/auth/testutil/tx/suite.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testutil
package tx

import (
"bytes"
Expand Down
4 changes: 2 additions & 2 deletions x/auth/tx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
txtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil/tx"
)

func TestGenerator(t *testing.T) {
interfaceRegistry := codectypes.NewInterfaceRegistry()
std.RegisterInterfaces(interfaceRegistry)
interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{})
protoCodec := codec.NewProtoCodec(interfaceRegistry)
suite.Run(t, testutil.NewTxConfigTestSuite(NewTxConfig(protoCodec, DefaultSignModes)))
suite.Run(t, txtestutil.NewTxConfigTestSuite(NewTxConfig(protoCodec, DefaultSignModes)))
}
4 changes: 3 additions & 1 deletion x/auth/types/account_retriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)

func TestAccountRetriever(t *testing.T) {
cfg := network.DefaultConfig()
cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig)
require.NoError(t, err)
cfg.NumValidators = 1

network, err := network.New(t, t.TempDir(), cfg)
Expand Down

0 comments on commit 77c764c

Please sign in to comment.