Skip to content

Commit

Permalink
fix integration test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Aug 28, 2024
1 parent a9b39dd commit e2733be
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 226 deletions.
178 changes: 0 additions & 178 deletions tests/integration/provider_gov_hooks.go

This file was deleted.

5 changes: 2 additions & 3 deletions tests/integration/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ func (suite *CCVTestSuite) SetupTest() {
// 1. the consumer chain is added to the coordinator
// 2. MakeGenesis is called on the provider chain
// 3. ibc/testing sets the tendermint header for the consumer chain app

providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
preProposalKeyAssignment(suite, icstestingutils.FirstConsumerId)
providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerID, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
preProposalKeyAssignment(suite, icstestingutils.FirstConsumerID)

// start consumer chains
suite.consumerBundles = make(map[string]*icstestingutils.ConsumerBundle)
Expand Down
18 changes: 11 additions & 7 deletions testutil/ibc_testing/generic_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const (
)

var (
FirstConsumerId string
firstConsumerChainID string
FirstConsumerID string
provChainID string
democConsumerChainID string
consumerTopNParams [NumConsumers]uint32
Expand All @@ -47,7 +48,8 @@ var (
func init() {
// Disable revision format
ibctesting.ChainIDSuffix = ""
FirstConsumerId = "2"
firstConsumerChainID = ibctesting.GetChainID(2)
FirstConsumerID = ""
provChainID = ibctesting.GetChainID(1)
democConsumerChainID = ibctesting.GetChainID(5000)
// TopN parameter values per consumer chain initiated
Expand Down Expand Up @@ -153,7 +155,10 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
powerShapingParameters := testkeeper.GetTestPowerShapingParameters()
powerShapingParameters.Top_N = consumerTopNParams[index] // isn't used in CreateConsumerClient

consumerId := fmt.Sprintf("%d", index+2)
consumerId := providerKeeper.FetchAndIncrementConsumerId(providerChain.GetContext())
if chainID == firstConsumerChainID {
FirstConsumerID = consumerId
}
providerKeeper.SetConsumerChainId(providerChain.GetContext(), consumerId, chainID)
providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata)
providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters)
Expand All @@ -180,14 +185,13 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
providerChain.GetContext(),
consumerId,
)
s.Require().True(found, "consumer genesis not found in AddConsumer")

foo, found := providerKeeper.GetConsumerClientId(
_, found = providerKeeper.GetConsumerClientId(
providerChain.GetContext(),
consumerId,
)
_ = foo

s.Require().True(found, "consumer genesis not found in AddConsumer")
s.Require().True(found, "clientID not found in AddConsumer")

// use InitialValSet as the valset on the consumer
var valz []*tmtypes.Validator
Expand Down
45 changes: 7 additions & 38 deletions testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,23 +282,18 @@ func GetTestConsumerMetadata() providertypes.ConsumerMetadata {
}

func GetTestInitializationParameters() providertypes.ConsumerInitializationParameters {
initialHeight := clienttypes.NewHeight(4, 5)
spawnTime := time.Now().UTC()
ccvTimeoutPeriod := types.DefaultCCVTimeoutPeriod
transferTimeoutPeriod := types.DefaultTransferTimeoutPeriod
unbondingPeriod := types.DefaultConsumerUnbondingPeriod
return providertypes.ConsumerInitializationParameters{
InitialHeight: initialHeight,
InitialHeight: clienttypes.NewHeight(4, 5),
GenesisHash: []byte("gen_hash"),
BinaryHash: []byte("bin_hash"),
SpawnTime: spawnTime,
SpawnTime: time.Now().UTC(),
ConsumerRedistributionFraction: types.DefaultConsumerRedistributeFrac,
BlocksPerDistributionTransmission: types.DefaultBlocksPerDistributionTransmission,
DistributionTransmissionChannel: "",
HistoricalEntries: types.DefaultHistoricalEntries,
CcvTimeoutPeriod: ccvTimeoutPeriod,
TransferTimeoutPeriod: transferTimeoutPeriod,
UnbondingPeriod: unbondingPeriod,
CcvTimeoutPeriod: types.DefaultCCVTimeoutPeriod,
TransferTimeoutPeriod: types.DefaultTransferTimeoutPeriod,
UnbondingPeriod: types.DefaultConsumerUnbondingPeriod,
}
}

Expand All @@ -309,37 +304,11 @@ func GetTestPowerShapingParameters() providertypes.PowerShapingParameters {
ValidatorSetCap: 0,
Allowlist: nil,
Denylist: nil,
MinStake: 0,
AllowInactiveVals: false,
}
}

func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal {
prop := providertypes.NewConsumerAdditionProposal(
"chainID",
"description",
"chainID",
clienttypes.NewHeight(4, 5),
[]byte("gen_hash"),
[]byte("bin_hash"),
time.Now(),
types.DefaultConsumerRedistributeFrac,
types.DefaultBlocksPerDistributionTransmission,
"",
types.DefaultHistoricalEntries,
types.DefaultCCVTimeoutPeriod,
types.DefaultTransferTimeoutPeriod,
types.DefaultConsumerUnbondingPeriod,
0,
0,
0,
nil,
nil,
0,
false,
).(*providertypes.ConsumerAdditionProposal)

return prop
}

func GetTestMsgUpdateConsumer() providertypes.MsgUpdateConsumer {
return providertypes.MsgUpdateConsumer{
Signer: "signer",
Expand Down

0 comments on commit e2733be

Please sign in to comment.