Skip to content

Commit

Permalink
Fix setup
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Mar 25, 2024
1 parent 252cc59 commit 3f73ba2
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/mbt/driver/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/stretchr/testify/require"

ce "github.com/cometbft/cometbft/crypto/encoding"

"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -375,10 +377,6 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC
stakingValidators = append(stakingValidators, v)
}

considerAll := func(validator stakingtypes.Validator) bool { return true }
nextValidators := s.providerKeeper().ComputeNextEpochConsumerValSet(s.providerCtx(), string(consumerChainId), stakingValidators, considerAll)
s.providerKeeper().SetConsumerValSet(s.providerCtx(), string(consumerChainId), nextValidators)

err = s.providerKeeper().SetConsumerGenesis(
providerChain.GetContext(),
string(consumerChainId),
Expand All @@ -395,6 +393,11 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC
s.providerKeeper().HandleOptIn(s.providerCtx(), consumerChain.ChainID, *addr, nil)
}

nextValidators := s.providerKeeper().ComputeNextEpochConsumerValSet(s.providerCtx(), string(consumerChainId), stakingValidators, func(validator stakingtypes.Validator) bool {
return s.providerKeeper().ShouldConsiderOnlyOptIn(s.providerCtx(), string(consumerChainId), validator)
})
s.providerKeeper().SetConsumerValSet(s.providerCtx(), string(consumerChainId), nextValidators)

// Client ID is set in InitGenesis and we treat it as a black box. So
// must query it to use it with the endpoint.
clientID, _ := s.consumerKeeper(consumerChainId).GetProviderClientID(s.ctx(consumerChainId))
Expand Down Expand Up @@ -482,6 +485,18 @@ func (s *Driver) setupConsumer(
s.coordinator.Chains[chain] = consumerChain

valUpdates := cmttypes.TM2PB.ValidatorUpdates(&initValSet)
consumerVals := make([]providertypes.ConsumerValidator, len(initValSet.Validators))
for i, val := range initValSet.Validators {
pk, err := ce.PubKeyToProto(val.PubKey)
require.NoError(s.t, err)

consumerVals[i] = providertypes.ConsumerValidator{
ProviderConsAddr: val.Address,
Power: val.VotingPower,
ConsumerPublicKey: &pk,
}
}
s.providerKeeper().SetConsumerValSet(s.providerCtx(), chain, consumerVals)

path := s.ConfigureNewPath(consumerChain, providerChain, params, uint32(topN), validatorsToOptIn, valUpdates)
s.simibcs[ChainId(chain)] = simibc.MakeRelayedPath(s.t, path)
Expand Down

0 comments on commit 3f73ba2

Please sign in to comment.