Skip to content

Commit

Permalink
Merge branch 'master' into am/fix-cli-msg
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 authored Aug 17, 2021
2 parents 7c2bc6d + 23e864b commit 10f240b
Show file tree
Hide file tree
Showing 88 changed files with 282 additions and 242 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#9576](https://github.com/cosmos/cosmos-sdk/pull/9576) Add debug error message to `sdkerrors.QueryResult` when enabled
* [\#9650](https://github.com/cosmos/cosmos-sdk/pull/9650) Removed deprecated message handler implementation from the SDK modules.
* (x/bank) [\#9832] (https://github.com/cosmos/cosmos-sdk/pull/9832) `AddressFromBalancesStore` renamed to `AddressAndDenomFromBalancesStore`.
* (tests) [\#9938](https://github.com/cosmos/cosmos-sdk/pull/9938) `simapp.Setup` accepts additional `testing.T` argument.


### Client Breaking Changes

Expand Down
18 changes: 18 additions & 0 deletions docs/run-node/run-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ The `~/.simapp` folder has the following structure:
|- priv_validator_key.json # Private key to use as a validator in the consensus protocol.
```

## Updating Some Default Settings

If you want to change any field values in configuration files (for ex: genesis.json) you can use `jq` ([installation](https://stedolan.github.io/jq/download/) & [docs](https://stedolan.github.io/jq/manual/#Assignment)) & `sed` commands to do that. Few examples are listed here.
```bash
# to change the chain-id
jq '.chain_id = "testing"' genesis.json > temp.json && mv temp.json genesis.json

# to enable the api server
sed -i '/\[api\]/,+3 s/enable = false/enable = true/' app.toml

# to change the voting_period
jq '.app_state.gov.voting_params.voting_period = "600s"' genesis.json > temp.json && mv temp.json genesis.json

# to change the inflation
jq '.app_state.mint.minter.inflation = "0.300000000000000000"' genesis.json > temp.json && mv temp.json genesis.json
```

## Adding Genesis Accounts
Before starting the chain, you need to populate the state with at least one account. To do so, first [create a new account in the keyring](./keyring.md#adding-keys-to-the-keyring) named `my_validator` under the `test` keyring backend (feel free to choose another name and another backend).

Now that you have created a local account, go ahead and grant it some `stake` tokens in your chain's genesis file. Doing so will also make sure your chain is aware of this account's existence:
Expand Down
2 changes: 1 addition & 1 deletion server/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type IntegrationTestSuite struct {

func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
s.app = simapp.Setup(false)
s.app = simapp.Setup(s.T(), false)
s.cfg = network.DefaultConfig()
s.cfg.NumValidators = 1

Expand Down
8 changes: 4 additions & 4 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
}

// Setup initializes a new SimApp. A Nop logger is set in SimApp.
func Setup(isCheckTx bool) *SimApp {
func Setup(t *testing.T, isCheckTx bool) *SimApp {
t.Helper()

app, genesisState := setup(!isCheckTx, 5)
if !isCheckTx {
// init chain must be called to stop deliverState from being nil
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
panic(err)
}
require.NoError(t, err)

// Initialize the chain
app.InitChain(
Expand Down
9 changes: 5 additions & 4 deletions types/query/filtered_pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package query_test

import (
"fmt"
"testing"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
Expand All @@ -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++ {
Expand Down Expand Up @@ -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++ {
Expand Down Expand Up @@ -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++ {
Expand Down
12 changes: 6 additions & 6 deletions types/query/pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/sigverify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (suite *AnteTestSuite) TestSigVerification() {
// In the meantime, we want to make double-sure amino compatibility works.
// ref: https://github.com/cosmos/cosmos-sdk/issues/7229
func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() {
suite.app, suite.ctx = createTestApp(true)
suite.app, suite.ctx = createTestApp(suite.T(), true)
suite.ctx = suite.ctx.WithBlockHeight(1)

// Set up TxConfig.
Expand Down
6 changes: 3 additions & 3 deletions x/auth/ante/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type AnteTestSuite struct {
}

// returns context and app with params set on account keeper
func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(isCheckTx)
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())

Expand All @@ -51,7 +51,7 @@ func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) {

// SetupTest setups a new test, with new app, context, and anteHandler.
func (suite *AnteTestSuite) SetupTest(isCheckTx bool) {
suite.app, suite.ctx = createTestApp(isCheckTx)
suite.app, suite.ctx = createTestApp(suite.T(), isCheckTx)
suite.ctx = suite.ctx.WithBlockHeight(1)

// Set up TxConfig.
Expand Down
6 changes: 4 additions & 2 deletions x/auth/keeper/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper_test

import (
"testing"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/simapp"
Expand All @@ -9,8 +11,8 @@ import (
)

// returns context and app with params set on account keeper
func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(isCheckTx)
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())

Expand Down
4 changes: 2 additions & 2 deletions x/auth/keeper/keeper_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func BenchmarkAccountMapperGetAccountFound(b *testing.B) {
b.ReportAllocs()
app, ctx := createTestApp(false)
app, ctx := createTestApp(&testing.T{}, false)

// assumes b.N < 2**24
for i := 0; i < b.N; i++ {
Expand All @@ -27,7 +27,7 @@ func BenchmarkAccountMapperGetAccountFound(b *testing.B) {

func BenchmarkAccountMapperSetAccount(b *testing.B) {
b.ReportAllocs()
app, ctx := createTestApp(false)
app, ctx := createTestApp(&testing.T{}, false)

b.ResetTimer()

Expand Down
10 changes: 5 additions & 5 deletions x/auth/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type KeeperTestSuite struct {
}

func (suite *KeeperTestSuite) SetupTest() {
suite.app, suite.ctx = createTestApp(true)
suite.app, suite.ctx = createTestApp(suite.T(), true)

queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
types.RegisterQueryServer(queryHelper, suite.app.AccountKeeper)
Expand All @@ -46,7 +46,7 @@ func TestKeeperTestSuite(t *testing.T) {
}

func TestAccountMapperGetSet(t *testing.T) {
app, ctx := createTestApp(true)
app, ctx := createTestApp(t, true)
addr := sdk.AccAddress([]byte("some---------address"))

// no account before its created
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestAccountMapperGetSet(t *testing.T) {
}

func TestAccountMapperRemoveAccount(t *testing.T) {
app, ctx := createTestApp(true)
app, ctx := createTestApp(t, true)
addr1 := sdk.AccAddress([]byte("addr1---------------"))
addr2 := sdk.AccAddress([]byte("addr2---------------"))

Expand Down Expand Up @@ -109,7 +109,7 @@ func TestAccountMapperRemoveAccount(t *testing.T) {
}

func TestGetSetParams(t *testing.T) {
app, ctx := createTestApp(true)
app, ctx := createTestApp(t, true)
params := types.DefaultParams()

app.AccountKeeper.SetParams(ctx, params)
Expand All @@ -119,7 +119,7 @@ func TestGetSetParams(t *testing.T) {
}

func TestSupply_ValidatePermissions(t *testing.T) {
app, _ := createTestApp(true)
app, _ := createTestApp(t, true)

// add module accounts to supply keeper
maccPerms := simapp.GetMaccPerms()
Expand Down
2 changes: 1 addition & 1 deletion x/auth/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestQueryAccount(t *testing.T) {
app, ctx := createTestApp(true)
app, ctx := createTestApp(t, true)
legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino())

req := abci.RequestQuery{
Expand Down
2 changes: 1 addition & 1 deletion x/auth/migrations/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func TestMigrateVestingAccounts(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
app := simapp.Setup(false)
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{
Time: time.Now(),
})
Expand Down
2 changes: 1 addition & 1 deletion x/auth/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
app := simapp.Setup(false)
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.InitChain(
Expand Down
6 changes: 3 additions & 3 deletions x/auth/signing/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestVerifySignature(t *testing.T) {
chainId = "test-chain"
)

app, ctx := createTestApp(false)
app, ctx := createTestApp(t, false)
ctx = ctx.WithBlockHeight(1)

cdc := codec.NewLegacyAmino()
Expand Down Expand Up @@ -97,8 +97,8 @@ func TestVerifySignature(t *testing.T) {
}

// returns context and app with params set on account keeper
func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(isCheckTx)
func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(t, isCheckTx)
ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
app.AccountKeeper.SetParams(ctx, types.DefaultParams())

Expand Down
2 changes: 1 addition & 1 deletion x/auth/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
)

func TestDecodeStore(t *testing.T) {
app := simapp.Setup(false)
app := simapp.Setup(t, false)
cdc := simapp.MakeTestEncodingConfig().Codec
acc := types.NewBaseAccountWithAddress(delAddr1)
dec := simulation.NewDecodeStore(app.AccountKeeper)
Expand Down
2 changes: 2 additions & 0 deletions x/auth/types/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
yaml "gopkg.in/yaml.v2"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -59,6 +60,7 @@ func TestBaseSequence(t *testing.T) {
}

func TestBaseAccountMarshal(t *testing.T) {
app := simapp.Setup(t, false)
_, pub, addr := testdata.KeyTestPubAddr()
acc := types.NewBaseAccountWithAddress(addr)
seq := uint64(7)
Expand Down
1 change: 0 additions & 1 deletion x/auth/types/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
)

var (
app = simapp.Setup(false)
ecdc = simapp.MakeTestEncodingConfig()
appCodec, legacyAmino = ecdc.Codec, ecdc.Amino
)
9 changes: 0 additions & 9 deletions x/auth/vesting/types/common_test.go

This file was deleted.

Loading

0 comments on commit 10f240b

Please sign in to comment.