Skip to content

Commit

Permalink
imp: add version to tm headers in ibctesting (release/v7.5.x) (#6180)
Browse files Browse the repository at this point in the history
* imp: add version to tm headers in ibctesting

* rm junk 08-wasm data dirs

* chore: adding changelog
  • Loading branch information
damiannolan authored May 6, 2024
1 parent b78afb0 commit 29dd2f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

* (apps/27-interchain-accounts) [\#6147](https://github.com/cosmos/ibc-go/pull/6147) Emit an event signalling that the host submodule is disabled.
* (testing) [\#6180](https://github.com/cosmos/ibc-go/pull/6180) Add version to tm abci headers in ibctesting.

### Features

Expand Down
8 changes: 8 additions & 0 deletions testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -62,6 +63,10 @@ func SetupTestingApp() (TestingApp, map[string]json.RawMessage) {
// of one consensus engine unit (10^6) in the default token of the simapp from first genesis
// account. A Nop logger is set in SimApp.
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp {
return SetupWithGenesisValSetAndConsensusParams(t, simapp.DefaultConsensusParams, valSet, genAccs, chainID, powerReduction, balances...)
}

func SetupWithGenesisValSetAndConsensusParams(t *testing.T, consensusParams *tmproto.ConsensusParams, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp {
app, genesisState := DefaultTestingAppInit()

// ensure baseapp has a chain-id set before running InitChain
Expand Down Expand Up @@ -136,6 +141,9 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
app.BeginBlock(
abci.RequestBeginBlock{
Header: tmproto.Header{
Version: tmprotoversion.Consensus{
App: consensusParams.Version.App,
},
ChainID: chainID,
Height: app.LastBlockHeight() + 1,
AppHash: app.LastCommitID().Hash,
Expand Down
6 changes: 5 additions & 1 deletion testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, chainID string, va

// create current header and call begin block
header := tmproto.Header{
Version: tmprotoversion.Consensus{
App: simapp.DefaultAppVersion,
},
ChainID: chainID,
Height: 1,
Time: coord.CurrentTime.UTC(),
Expand Down Expand Up @@ -296,6 +299,7 @@ func (chain *TestChain) NextBlock() {
chain.CurrentHeader = tmproto.Header{
ChainID: chain.ChainID,
Height: chain.App.LastBlockHeight() + 1,
Version: chain.CurrentHeader.Version,
AppHash: chain.App.LastCommitID().Hash,
// NOTE: the time is increased by the coordinator to maintain time synchrony amongst
// chains.
Expand Down Expand Up @@ -476,7 +480,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64,
nextValHash := nextVals.Hash()

tmHeader := tmtypes.Header{
Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2},
Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: simapp.DefaultAppVersion},
ChainID: chainID,
Height: blockHeight,
Time: timestamp,
Expand Down
5 changes: 5 additions & 0 deletions testing/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/cosmos/ibc-go/v7/testing/mock"
)

var DefaultAppVersion uint64 = 1

// DefaultConsensusParams defines the default Tendermint consensus params used in
// SimApp testing.
var DefaultConsensusParams = &tmproto.ConsensusParams{
Expand All @@ -44,6 +46,9 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{
tmtypes.ABCIPubKeyTypeEd25519,
},
},
Version: &tmproto.VersionParams{
App: DefaultAppVersion,
},
}

func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
Expand Down

0 comments on commit 29dd2f3

Please sign in to comment.