Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed May 3, 2024
1 parent 7ac70f8 commit 9edc79b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 277 deletions.
48 changes: 13 additions & 35 deletions app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,6 @@ func NewContextForApp(app composable.ComposableApp) sdk.Context {
return ctx
}

func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *composable.ComposableApp {
t.Helper()
app, genesisState := setup(!isCheckTx, invCheckPeriod)
if !isCheckTx {
// InitChain must be called to stop deliverState from being nil
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)

// Initialize the chain
app.InitChain(
&abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
}

return app
}

func setup(withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*composable.ComposableApp, composable.GenesisState) {
db := dbm.NewMemDB()
encCdc := composable.MakeEncodingConfig()
Expand Down Expand Up @@ -118,28 +97,27 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
baseapp.SetChainID(chainID)(app.GetBaseApp())

// init chain will set the validator set and initialize the genesis accounts
app.InitChain(
_, err = app.InitChain(
&abci.RequestInitChain{
ChainId: chainID,
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
InitialHeight: app.LastBlockHeight() + 1,
AppStateBytes: stateBytes,
},
)
if err != nil {
panic(err)
}

// commit genesis changes
// app.BaseApp.Set
app.Commit()
//* (baseapp) [#15519](https://github.com/cosmos/cosmos-sdk/pull/15519/files) BeginBlock and EndBlock are now internal to baseapp. For testing, user must call `FinalizeBlock`. BeginBlock and EndBlock calls are internal to Baseapp.
app.FinalizeBlock(
&abci.RequestFinalizeBlock{
// ChainID: chainID,
Height: app.LastBlockHeight() + 1,
// AppHash: app.LastCommitID().Hash,
// ValidatorsHash: valSet.Hash(),
NextValidatorsHash: valSet.Hash(),
},
)
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: app.LastBlockHeight() + 1,
Hash: app.LastCommitID().Hash,
NextValidatorsHash: valSet.Hash(),
})
if err != nil {
panic(err)
}

return app
}
Expand Down
9 changes: 5 additions & 4 deletions app/ibctesting/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ChainApp interface {
GetIBCKeeper() *ibckeeper.Keeper
GetBankKeeper() bankkeeper.Keeper
GetStakingKeeper() *stakingkeeper.Keeper
GetGovKeeper() *govkeeper.Keeper
GetAccountKeeper() authkeeper.AccountKeeper
GetWasmKeeper() wasmkeeper.Keeper
GetPfmKeeper() packetforwardkeeper.Keeper
Expand Down Expand Up @@ -769,20 +770,20 @@ func (chain *TestChain) QueryContract(suite *suite.Suite, contract sdk.AccAddres

//
//func (chain *TestChain) StoreContractCode(suite *suite.Suite, path string) {
// govModuleAddress := chain.GetTestSupport().AccountKeeper().GetModuleAddress(govtypes.ModuleName)
// govModuleAddress := chain.App.GetAccountKeeper().GetModuleAddress(govtypes.ModuleName)
// wasmCode, err := os.ReadFile(path)
// suite.Require().NoError(err)
//
// src := wasmtypes.StoreCodeProposalFixture(func(p *wasmtypes.StoreCodeProposal) { //nolint: staticcheck
// src := wasmtypes.New(func(p *wasmtypes.StoreCodeProposal) { //nolint: staticcheck
// p.RunAs = govModuleAddress.String()
// p.WASMByteCode = wasmCode
// checksum := sha256.Sum256(wasmCode)
// p.CodeHash = checksum[:]
// })
//
// govKeeper := chain.GetTestSupport().GovKeeper()
// govKeeper := chain.App.GetGovKeeper()
// // when
// mustSubmitAndExecuteLegacyProposal(suite.T(), chain.GetContext(), src, chain.SenderAccount.GetAddress().String(), &govKeeper, govModuleAddress.String())
// mustSubmitAndExecuteLegacyProposal(suite.T(), chain.GetContext(), src, chain.SenderAccount.GetAddress().String(), govKeeper, govModuleAddress.String())
// suite.Require().NoError(err)
//}

Expand Down
5 changes: 5 additions & 0 deletions app/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/keeper"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
Expand Down Expand Up @@ -60,6 +61,10 @@ func (app *ComposableApp) GetTransferMiddlewareKeeper() transfermiddlewarekeeper
return app.TransferMiddlewareKeeper
}

func (app *ComposableApp) GetGovKeeper() *govkeeper.Keeper {
return &app.GovKeeper
}

// GetTxConfig implements the TestingApp interface.
func (app *ComposableApp) GetTxConfig() client.TxConfig {
cfg := MakeEncodingConfig()
Expand Down
238 changes: 0 additions & 238 deletions x/ibc-hooks/relay_test.go

This file was deleted.

0 comments on commit 9edc79b

Please sign in to comment.