Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove setting of finalizeBlockState in FinalizeBlock + fix initialHeight + add ProcessProposal in tests/sims #16794

Merged
merged 11 commits into from
Jul 6, 2023
Prev Previous commit
Next Next commit
fix more tests
  • Loading branch information
facundomedica committed Jul 3, 2023
commit 7228c67bca92e22f52b6d5081608419cd9a790dc
9 changes: 8 additions & 1 deletion server/mock/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestInitApp(t *testing.T) {
require.Equal(t, []byte("bar"), qres.Value)
}

func TestDeliverTx(t *testing.T) {
func TestFinalizeBlock(t *testing.T) {
app := SetupApp(t)

key := "my-special-key"
Expand All @@ -72,6 +72,13 @@ func TestDeliverTx(t *testing.T) {
tx := NewTx(key, value, randomAccounts[0].Address)
txBytes := tx.GetSignBytes()

_, err := app.ProcessProposal(&abci.RequestProcessProposal{
Hash: []byte("apphash"),
Height: 1,
Txs: [][]byte{txBytes},
})
require.NoError(t, err)

res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
Hash: []byte("apphash"),
Height: 1,
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/server/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func TestExportCmd_Height(t *testing.T) {

// Fast forward to block `tc.fastForward`.
for i := int64(2); i <= tc.fastForward; i++ {
app.ProcessProposal(&abci.RequestProcessProposal{
Height: i,
})

app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: i,
})
Expand Down
5 changes: 4 additions & 1 deletion x/slashing/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ func TestSlashingMsgs(t *testing.T) {
require.NoError(t, err)
require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1)))

app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
_, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)

ctxCheck = baseApp.NewContext(true)
validator, err := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1))
Expand Down
8 changes: 8 additions & 0 deletions x/staking/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func TestStakingMsgs(t *testing.T) {
require.NoError(t, err)
require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1)))

_, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)
ctxCheck = app.BaseApp.NewContext(true)
Expand All @@ -89,6 +91,8 @@ func TestStakingMsgs(t *testing.T) {
require.Equal(t, types.Bonded, validator.Status)
require.True(math.IntEq(t, bondTokens, validator.BondedTokens()))

_, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)

Expand All @@ -110,6 +114,8 @@ func TestStakingMsgs(t *testing.T) {
delegateMsg := types.NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin)

header = cmtproto.Header{Height: app.LastBlockHeight() + 1}
_, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height})
require.NoError(t, err)
_, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2)
require.NoError(t, err)

Expand All @@ -121,6 +127,8 @@ func TestStakingMsgs(t *testing.T) {
// begin unbonding
beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin)
header = cmtproto.Header{Height: app.LastBlockHeight() + 1}
_, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height})
require.NoError(t, err)
_, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2)
require.NoError(t, err)

Expand Down