feat!: Comet v0.38 Integration (#15519)
Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
marbar3778
cool-developer
Aaron Craelius
Matt Kocubinski
Julien Robert
parent
166be3766b
commit
6cee22df52
@@ -157,23 +157,24 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon
|
||||
}
|
||||
|
||||
// init chain will set the validator set and initialize the genesis accounts
|
||||
app.InitChain(
|
||||
abci.RequestInitChain{
|
||||
Validators: []abci.ValidatorUpdate{},
|
||||
ConsensusParams: DefaultConsensusParams,
|
||||
AppStateBytes: stateBytes,
|
||||
},
|
||||
)
|
||||
_, err = app.InitChain(&abci.RequestInitChain{
|
||||
Validators: []abci.ValidatorUpdate{},
|
||||
ConsensusParams: DefaultConsensusParams,
|
||||
AppStateBytes: stateBytes,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to init chain: %w", err)
|
||||
}
|
||||
|
||||
// commit genesis changes
|
||||
if !startupConfig.AtGenesis {
|
||||
app.Commit()
|
||||
app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{
|
||||
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
Height: app.LastBlockHeight() + 1,
|
||||
AppHash: app.LastCommitID().Hash,
|
||||
ValidatorsHash: valSet.Hash(),
|
||||
NextValidatorsHash: valSet.Hash(),
|
||||
}})
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to finalize block: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return app, nil
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
types2 "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -120,20 +121,33 @@ func SignCheckDeliver(
|
||||
require.Nil(t, res)
|
||||
}
|
||||
|
||||
// Simulate a sending a transaction and committing a block
|
||||
app.BeginBlock(types2.RequestBeginBlock{Header: header})
|
||||
gInfo, res, err := app.SimDeliver(txCfg.TxEncoder(), tx)
|
||||
bz, err := txCfg.TxEncoder()(tx)
|
||||
require.NoError(t, err)
|
||||
|
||||
resBlock, err := app.FinalizeBlock(&types2.RequestFinalizeBlock{
|
||||
Height: header.Height,
|
||||
Txs: [][]byte{bz},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, 1, len(resBlock.TxResults))
|
||||
txResult := resBlock.TxResults[0]
|
||||
finalizeSuccess := txResult.Code == 0
|
||||
if expPass {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, res)
|
||||
require.True(t, finalizeSuccess)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
require.Nil(t, res)
|
||||
require.False(t, finalizeSuccess)
|
||||
}
|
||||
|
||||
app.EndBlock(types2.RequestEndBlock{})
|
||||
app.Commit()
|
||||
|
||||
return gInfo, res, err
|
||||
gInfo := sdk.GasInfo{GasWanted: uint64(txResult.GasWanted), GasUsed: uint64(txResult.GasUsed)}
|
||||
txRes := sdk.Result{Data: txResult.Data, Log: txResult.Log, Events: txResult.Events}
|
||||
if finalizeSuccess {
|
||||
err = nil
|
||||
} else {
|
||||
err = errors.ABCIError(txResult.Codespace, txResult.Code, txResult.Log)
|
||||
}
|
||||
|
||||
return gInfo, &txRes, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user