From 0a5803396b8e7c7726426fe0425ae5138b79ecfe Mon Sep 17 00:00:00 2001 From: son trinh Date: Sun, 21 Jul 2024 19:24:56 +0700 Subject: [PATCH 1/4] fix: NewIntegrationApp does not write default genesis to state (#21006) (cherry picked from commit 6f1592d3da374efb47fa06dc7a74f380e24cb4ee) # Conflicts: # testutil/integration/router.go --- CHANGELOG.md | 1 + testutil/integration/router.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96e6c98fe143..b1ea94db8fc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#20939](https://github.com/cosmos/cosmos-sdk/pull/20939) Fix collection reverse iterator to include `pagination.key` in the result. * (client/grpc) [#20969](https://github.com/cosmos/cosmos-sdk/pull/20969) Fix `node.NewQueryServer` method not setting `cfg`. +* (testutil/integration) [#21006](https://github.com/cosmos/cosmos-sdk/pull/21006) Fix `NewIntegrationApp` method not writing default genesis to state ## [v0.50.8](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.8) - 2024-07-15 diff --git a/testutil/integration/router.go b/testutil/integration/router.go index 4270d493ad8c..e100caeb04b0 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -59,10 +59,19 @@ func NewIntegrationApp( bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName)) bApp.MountKVStores(keys) +<<<<<<< HEAD bApp.SetInitChainer(func(ctx sdk.Context, _ *cmtabcitypes.RequestInitChain) (*cmtabcitypes.ResponseInitChain, error) { for _, mod := range modules { if m, ok := mod.(module.HasGenesis); ok { m.InitGenesis(ctx, appCodec, m.DefaultGenesis(appCodec)) +======= + bApp.SetInitChainer(func(_ sdk.Context, _ *cmtabcitypes.InitChainRequest) (*cmtabcitypes.InitChainResponse, error) { + for _, mod := range modules { + if m, ok := mod.(module.HasGenesis); ok { + if err := m.InitGenesis(sdkCtx, m.DefaultGenesis()); err != nil { + return nil, err + } +>>>>>>> 6f1592d3d (fix: NewIntegrationApp does not write default genesis to state (#21006)) } } From dae3d1121bd8020fbb76896c375ae0397a622da1 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 21 Jul 2024 19:37:20 +0700 Subject: [PATCH 2/4] fix --- testutil/integration/router.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/testutil/integration/router.go b/testutil/integration/router.go index e100caeb04b0..a96c7d72d197 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -59,19 +59,10 @@ func NewIntegrationApp( bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName)) bApp.MountKVStores(keys) -<<<<<<< HEAD - bApp.SetInitChainer(func(ctx sdk.Context, _ *cmtabcitypes.RequestInitChain) (*cmtabcitypes.ResponseInitChain, error) { + bApp.SetInitChainer(func(_ sdk.Context, _ *cmtabcitypes.RequestInitChain) (*cmtabcitypes.ResponseInitChain, error) { for _, mod := range modules { if m, ok := mod.(module.HasGenesis); ok { - m.InitGenesis(ctx, appCodec, m.DefaultGenesis(appCodec)) -======= - bApp.SetInitChainer(func(_ sdk.Context, _ *cmtabcitypes.InitChainRequest) (*cmtabcitypes.InitChainResponse, error) { - for _, mod := range modules { - if m, ok := mod.(module.HasGenesis); ok { - if err := m.InitGenesis(sdkCtx, m.DefaultGenesis()); err != nil { - return nil, err - } ->>>>>>> 6f1592d3d (fix: NewIntegrationApp does not write default genesis to state (#21006)) + m.InitGenesis(sdkCtx, appCodec, m.DefaultGenesis(appCodec)) } } From c93e935f5c5a1e54dfe4f7eb3a7f6e09660f94fe Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 21 Jul 2024 20:12:25 +0700 Subject: [PATCH 3/4] fix test --- tests/integration/distribution/keeper/msg_server_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index 86a2d8e626e2..6c21a4ee77a5 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -276,8 +276,9 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { } height := f.app.LastBlockHeight() - _, err = f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx) - assert.Error(t, err, "previous proposer not set") + proposerAddr, _ := f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx) + // the store key is set but + assert.Equal(t, proposerAddr.Empty(), true) for _, tc := range testCases { tc := tc From 6be822ca97c3d0cabdaf0df97fa581e89e7f6970 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Sun, 21 Jul 2024 20:12:59 +0700 Subject: [PATCH 4/4] minor --- tests/integration/distribution/keeper/msg_server_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index 6c21a4ee77a5..fbb883da63bc 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -277,7 +277,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { height := f.app.LastBlockHeight() proposerAddr, _ := f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx) - // the store key is set but assert.Equal(t, proposerAddr.Empty(), true) for _, tc := range testCases {