From b533d1ff802609c127d779ce5da598a45df4aa05 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Thu, 30 Nov 2023 14:13:45 +0100
Subject: [PATCH] Lint files
---
.../proposals_whitelisting_test.go | 3 +-
tests/mbt/driver/core.go | 121 +-----------------
tests/mbt/driver/mbt_test.go | 21 ++-
tests/mbt/driver/setup.go | 30 +++--
testutil/ibc_testing/generic_setup.go | 4 +-
testutil/integration/validators.go | 25 ++--
x/ccv/provider/types/proposal_test.go | 2 +-
7 files changed, 55 insertions(+), 151 deletions(-)
diff --git a/app/consumer-democracy/proposals_whitelisting_test.go b/app/consumer-democracy/proposals_whitelisting_test.go
index d0e5a7742d..a4b43cdffe 100644
--- a/app/consumer-democracy/proposals_whitelisting_test.go
+++ b/app/consumer-democracy/proposals_whitelisting_test.go
@@ -12,7 +12,8 @@ import (
)
func TestDemocracyGovernanceWhitelistingKeys(t *testing.T) {
- _, valUpdates, _ := testutil.CreateValidators(t, 4)
+ _, valUpdates, _, err := testutil.CreateValidators(4)
+ require.NoError(t, err)
ibctesting.DefaultTestingAppInit = icstestingutils.DemocracyConsumerAppIniter(valUpdates)
chain := ibctesting.NewTestChain(t, ibctesting.NewCoordinator(t, 0), "test")
paramKeeper := chain.App.(*appConsumer.App).ParamsKeeper
diff --git a/tests/mbt/driver/core.go b/tests/mbt/driver/core.go
index b17d72b390..417a286e77 100644
--- a/tests/mbt/driver/core.go
+++ b/tests/mbt/driver/core.go
@@ -13,7 +13,6 @@ import (
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
- slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -87,19 +86,10 @@ func (b *Driver) providerStakingKeeper() stakingkeeper.Keeper {
return *b.providerChain().App.(*appProvider.App).StakingKeeper
}
-func (b *Driver) providerSlashingKeeper() slashingkeeper.Keeper {
- return b.providerChain().App.(*appProvider.App).SlashingKeeper
-}
-
func (b *Driver) consumerKeeper(chain ChainId) consumerkeeper.Keeper {
return b.chain(chain).App.(*appConsumer.App).ConsumerKeeper
}
-// height returns the height of the current header of chain
-func (s *Driver) height(chain ChainId) int64 {
- return s.chain(chain).CurrentHeader.GetHeight()
-}
-
// runningTime returns the timestamp of the current header of chain
func (s *Driver) runningTime(chain ChainId) time.Time {
testChain := s.chain(chain)
@@ -112,15 +102,6 @@ func (s *Driver) lastTime(chain ChainId) time.Time {
return testChain.LastHeader.Header.Time
}
-func (s *Driver) allTimes() map[ChainId]time.Time {
- chains := s.coordinator.Chains
- times := make(map[ChainId]time.Time, len(chains))
- for _, chain := range chains {
- times[ChainId(chain.ChainID)] = chain.CurrentHeader.Time
- }
- return times
-}
-
// delegator retrieves the address for the delegator account
func (s *Driver) delegator() sdk.AccAddress {
return s.providerChain().SenderAccount.GetAddress()
@@ -131,25 +112,12 @@ func (s *Driver) validator(i int64) sdk.ValAddress {
return sdk.ValAddress(s.validators[i].Address)
}
-// consAddr returns the ConsAdd for the validator with id (ix) i
-func (s *Driver) consAddr(i int64) sdk.ConsAddress {
- return sdk.ConsAddress(s.validator(i))
-}
-
-// isJailed returns the jail status of validator with id (ix) i
-func (s *Driver) isJailed(i int64) bool {
- val, found := s.providerStakingKeeper().GetValidator(s.ctx(P), s.validator(i))
-
- require.True(s.t, found, "GetValidator(%v) -> !found", s.validator(i))
- return val.IsJailed()
-}
-
// consumerPower returns the power on the consumer chain chain for
// validator with id (ix) i
func (s *Driver) consumerPower(i int64, chain ChainId) (int64, error) {
v, found := s.consumerKeeper(chain).GetCCValidator(s.ctx(chain), s.validator(i))
if !found {
- return 0, fmt.Errorf("GetCCValidator(%v) -> !found", s.validator(i))
+ return 0, fmt.Errorf("validator %v not found", s.validator(i))
}
return v.Power, nil
}
@@ -159,41 +127,12 @@ func (s *Driver) consumerPower(i int64, chain ChainId) (int64, error) {
func (s *Driver) providerPower(i int64) (int64, error) {
v, found := s.providerStakingKeeper().GetValidator(s.ctx(P), s.validator(i))
if !found {
- return 0, fmt.Errorf("Validator with id %v not found on provider!", i)
+ return 0, fmt.Errorf("validator with id %v not found on provider", i)
} else {
return v.BondedTokens().Int64(), nil
}
}
-// delegation returns the number of delegated tokens in the delegation from
-// the delegator account to the validator with id (ix) i
-func (s *Driver) delegation(i int64) int64 {
- d, found := s.providerStakingKeeper().GetDelegation(s.ctx(P), s.delegator(), s.validator(i))
- require.True(s.t, found, "GetDelegation(%v) -> !found", s.validator(i))
- return d.Shares.TruncateInt64()
-}
-
-// validatorStatus returns the validator status for validator with id (ix) i
-// on the provider chain, and also whether the validator was found.
-// If the validator was not found, the status is returned as Unbonded.
-func (s *Driver) validatorStatus(i int64) (stakingtypes.BondStatus, bool) {
- v, found := s.providerStakingKeeper().GetValidator(s.ctx(P), s.validator(i))
- if !found {
- return stakingtypes.Unbonded, false
- }
- return v.GetStatus(), true
-}
-
-// providerTokens returns the number of tokens that the validator with
-// id (ix) i has delegated to it in total on the provider chain
-func (s *Driver) providerTokens(i int64) int64 {
- v, found := s.providerStakingKeeper().GetValidator(s.ctx(P), s.validator(i))
- if !found {
- return 0
- }
- return v.Tokens.Int64()
-}
-
func (s *Driver) providerValidatorSet() []stakingtypes.Validator {
return s.providerStakingKeeper().GetAllValidators(s.ctx(P))
}
@@ -202,13 +141,6 @@ func (s *Driver) consumerValidatorSet(chain ChainId) []consumertypes.CrossChainV
return s.consumerKeeper(chain).GetAllCCValidator(s.ctx(chain))
}
-// delegatorBalance returns the balance of the delegator account
-func (s *Driver) delegatorBalance() int64 {
- d := s.delegator()
- bal := s.providerChain().App.(*appProvider.App).BankKeeper.GetBalance(s.ctx(P), d, sdk.DefaultBondDenom)
- return bal.Amount.Int64()
-}
-
// delegate delegates amt tokens to validator val
func (s *Driver) delegate(val, amt int64) {
providerStaking := s.providerStakingKeeper()
@@ -236,28 +168,6 @@ func (s *Driver) undelegate(val, amt int64) {
providerStaking.GetAllDelegations(s.ctx(P))
}
-// consumerSlash simulates a slash event occurring on the consumer chain.
-// It can be for a downtime or doublesign.
-func (s *Driver) consumerSlash(val sdk.ConsAddress, h int64, isDowntime bool, chain ChainId) {
- kind := stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN
- if isDowntime {
- kind = stakingtypes.Infraction_INFRACTION_DOWNTIME
- }
- ctx := s.ctx(chain)
- before := len(ctx.EventManager().Events())
- s.consumerKeeper(chain).SlashWithInfractionReason(ctx, val, h, 0, sdk.Dec{}, kind)
- // consumer module emits packets on slash, so these must be collected.
- evts := ctx.EventManager().Events()
- packets := simibc.ParsePacketsFromEvents(evts[before:])
- if len(packets) > 0 {
- s.path(chain).Outboxes.AddPacket(string(chain), packets[0])
- }
-}
-
-func (s *Driver) updateClient(chain ChainId) error {
- return s.path(chain).UpdateClient(string(chain), false)
-}
-
// packetQueue returns the queued packet sfrom sender to receiver,
// where either sender or receiver must be the provider.
func (s *Driver) packetQueue(sender, receiver ChainId) []simibc.Packet {
@@ -277,14 +187,6 @@ func (s *Driver) packetQueue(sender, receiver ChainId) []simibc.Packet {
}
}
-func (s *Driver) getPacketsFromProviderToConsumer(consumer ChainId) []simibc.Packet {
- return s.path(consumer).Outboxes.OutboxPackets[string(consumer)]
-}
-
-func (s *Driver) getPacketsFromConsumerToProvider(consumer ChainId) []simibc.Packet {
- return s.path(consumer).Outboxes.OutboxPackets[P]
-}
-
func (s *Driver) getStateString() string {
var state strings.Builder
@@ -466,12 +368,6 @@ func (s *Driver) setTime(chain ChainId, newTime time.Time) {
testChain.App.BeginBlock(abcitypes.RequestBeginBlock{Header: testChain.CurrentHeader})
}
-func (s *Driver) setAllTimes(newTimes map[ChainId]time.Time) {
- for chain, newTime := range newTimes {
- s.setTime(chain, newTime)
- }
-}
-
// DeliverPacketToConsumer delivers a packet from the provider to the given consumer recipient.
// It updates the client before delivering the packet.
// Since the channel is ordered, the packet that is delivered is the first packet in the outbox.
@@ -491,19 +387,15 @@ func (s *Driver) DeliverPacketFromConsumer(sender ChainId, expectError bool) {
func (s *Driver) DeliverAcks() {
for _, chain := range s.runningConsumers() {
path := s.path(ChainId(chain.ChainId))
- path.DeliverAcks(string(path.Path.EndpointA.Chain.ChainID), math.MaxInt)
- path.DeliverAcks(string(path.Path.EndpointB.Chain.ChainID), math.MaxInt)
+ path.DeliverAcks(path.Path.EndpointA.Chain.ChainID, math.MaxInt)
+ path.DeliverAcks(path.Path.EndpointB.Chain.ChainID, math.MaxInt)
}
}
// stopConsumer stops a given consumer chain.
-func (s *Driver) stopConsumer(chain ChainId) {
+func (s *Driver) stopConsumer(chain ChainId) error {
// stop the consumer chain on the provider
- s.providerKeeper().StopConsumerChain(s.providerCtx(), string(chain), true)
- // delete the chain from the coordinator
- delete(s.coordinator.Chains, string(chain))
- // delete the path from the driver
- delete(s.simibcs, chain)
+ return s.providerKeeper().StopConsumerChain(s.providerCtx(), string(chain), true)
}
// newDriver creates a new Driver object.
@@ -511,6 +403,7 @@ func (s *Driver) stopConsumer(chain ChainId) {
// The caller must call setupChains to start the chains and
// fully populate the Driver.
func newDriver(t *testing.T, validators []*cmttypes.Validator, valNames []string) *Driver {
+ t.Helper()
t.Log("Creating coordinator")
coordinator := ibctesting.NewCoordinator(t, 0) // start without chains, which we add later
diff --git a/tests/mbt/driver/mbt_test.go b/tests/mbt/driver/mbt_test.go
index 35626e200a..3571d861cd 100644
--- a/tests/mbt/driver/mbt_test.go
+++ b/tests/mbt/driver/mbt_test.go
@@ -71,6 +71,7 @@ func TestMBT(t *testing.T) {
}
func RunItfTrace(t *testing.T, path string) {
+ t.Helper()
t.Logf("🟡 Testing trace %s", path)
// Load trace
@@ -140,7 +141,8 @@ func RunItfTrace(t *testing.T, path string) {
}
// initialValSet has the right vals, but not yet the right powers
- valSet, addressMap, signers := CreateValSet(t, initialValSet)
+ valSet, addressMap, signers, err := CreateValSet(initialValSet)
+ require.NoError(t, err, "Error creating validator set")
// get a slice of validators in the right order
nodes := make([]*cmttypes.Validator, len(valNames))
@@ -249,7 +251,10 @@ func RunItfTrace(t *testing.T, path string) {
// stop consumers
for _, consumer := range consumersToStop {
- driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumer.Value.(string), true)
+ err := driver.stopConsumer(ChainId(consumer.Value.(string)))
+ if err != nil {
+ log.Fatalf("Error stopping consumer %v: %v", consumer, err)
+ }
}
// reset the times for the consumers that were not stopped or started just now
@@ -264,7 +269,7 @@ func RunItfTrace(t *testing.T, path string) {
if len(consumersToStart) > 0 && consumer.ChainId == consumersToStart[len(consumersToStart)-1].Value.(string) {
continue
}
- consumerChainId := string(consumer.ChainId)
+ consumerChainId := consumer.ChainId
driver.path(ChainId(consumerChainId)).AddClientHeader(Provider, driver.providerHeader())
err := driver.path(ChainId(consumerChainId)).UpdateClient(consumerChainId, false)
@@ -363,7 +368,7 @@ func RunItfTrace(t *testing.T, path string) {
CompareValidatorSets(t, driver, currentModelState, actualRunningConsumers, index)
// check times - sanity check that the block times match the ones from the model
- CompareTimes(t, driver, actualRunningConsumers, currentModelState, timeOffset)
+ CompareTimes(driver, actualRunningConsumers, currentModelState, timeOffset)
// check sent packets: we check that the package queues in the model and the system have the same length.
for _, consumer := range actualRunningConsumers {
@@ -380,6 +385,7 @@ func RunItfTrace(t *testing.T, path string) {
}
func CompareValidatorSets(t *testing.T, driver *Driver, currentModelState map[string]itf.Expr, consumers []string, index int) {
+ t.Helper()
modelValSet := ValidatorSet(currentModelState, "provider")
curValSet := driver.providerValidatorSet()
@@ -387,7 +393,7 @@ func CompareValidatorSets(t *testing.T, driver *Driver, currentModelState map[st
for _, val := range curValSet {
valName := val.Description.Moniker
- actualValSet[valName] = int64(val.Tokens.Int64())
+ actualValSet[valName] = val.Tokens.Int64()
}
require.NoError(t, CompareValSet(modelValSet, actualValSet), "Validator sets do not match")
@@ -411,7 +417,7 @@ func CompareValidatorSets(t *testing.T, driver *Driver, currentModelState map[st
providerVal, found := driver.providerStakingKeeper().GetValidatorByConsAddr(driver.providerCtx(), providerConsAddr.Address)
require.True(t, found, "Error getting provider validator")
- consumerCurValSet[providerVal.GetMoniker()] = int64(val.Power)
+ consumerCurValSet[providerVal.GetMoniker()] = val.Power
}
for val, power := range modelValSet {
_ = val
@@ -432,6 +438,7 @@ func ComparePacketQueues(
consumer string,
timeOffset time.Time,
) {
+ t.Helper()
ComparePacketQueue(t, driver, currentModelState, Provider, consumer, timeOffset)
ComparePacketQueue(t, driver, currentModelState, consumer, Provider, timeOffset)
}
@@ -444,6 +451,7 @@ func ComparePacketQueue(
receiver string,
timeOffset time.Time,
) {
+ t.Helper()
modelSenderQueue := PacketQueue(currentModelState, sender, receiver)
actualSenderQueue := driver.packetQueue(ChainId(sender), ChainId(receiver))
@@ -477,7 +485,6 @@ func ComparePacketQueue(
// We only compare down to seconds, because the model and system will differ
// on the order of nanoseconds.
func CompareTimes(
- t *testing.T,
driver *Driver,
consumers []string,
currentModelState map[string]itf.Expr,
diff --git a/tests/mbt/driver/setup.go b/tests/mbt/driver/setup.go
index 021f48cbc2..24b2a36678 100644
--- a/tests/mbt/driver/setup.go
+++ b/tests/mbt/driver/setup.go
@@ -10,7 +10,6 @@ import (
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
- tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/stretchr/testify/require"
@@ -33,7 +32,6 @@ import (
"github.com/cosmos/interchain-security/v3/testutil/integration"
simibc "github.com/cosmos/interchain-security/v3/testutil/simibc"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
- ccv "github.com/cosmos/interchain-security/v3/x/ccv/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)
@@ -58,9 +56,12 @@ var (
// - a validator set
// - a map from node names to validator objects and
// - a map from validator addresses to private validators (signers)
-func CreateValSet(t *testing.T, initialValidatorSet map[string]int64) (*cmttypes.ValidatorSet, map[string]*cmttypes.Validator, map[string]cmttypes.PrivValidator) {
+func CreateValSet(initialValidatorSet map[string]int64) (*cmttypes.ValidatorSet, map[string]*cmttypes.Validator, map[string]cmttypes.PrivValidator, error) {
// create a valSet and signers, but the voting powers will not yet be right
- valSet, _, signers := integration.CreateValidators(t, len(initialValidatorSet))
+ valSet, _, signers, err := integration.CreateValidators(len(initialValidatorSet))
+ if err != nil {
+ return nil, nil, nil, err
+ }
// create a map from validator names to validators
valMap := make(map[string]*cmttypes.Validator)
@@ -87,7 +88,7 @@ func CreateValSet(t *testing.T, initialValidatorSet map[string]int64) (*cmttypes
// override the valSet by creating a new one with the right voting powers
valSet = cmttypes.NewValidatorSet(vals)
- return valSet, valMap, signers
+ return valSet, valMap, signers, nil
}
func getAppBytesAndSenders(
@@ -251,6 +252,7 @@ func newChain(
nodes []*cmttypes.Validator,
valNames []string,
) *ibctesting.TestChain {
+ t.Helper()
app, genesis := appInit()
baseapp.SetChainID(chainID)(app.GetBaseApp())
@@ -310,7 +312,7 @@ func newChain(
// Creates a path for cross-chain validation from the consumer to the provider and configures the channel config of the endpoints
// as well as the clients.
// this function stops when there is an initialized, ready-to-relay channel between the provider and consumer.
-func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestChain, params ModelParams, lastProviderHeader *ibctmtypes.Header) *ibctesting.Path {
+func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestChain, params ModelParams) *ibctesting.Path {
consumerChainId := ChainId(consumerChain.ChainID)
path := ibctesting.NewPath(consumerChain, providerChain)
@@ -388,7 +390,7 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC
// the same time and height. This is the starting point for all our
// data driven testing.
lastConsumerHeader, _ := simibc.EndBlock(consumerChain, func() {})
- lastProviderHeader, _ = simibc.EndBlock(providerChain, func() {})
+ lastProviderHeader, _ := simibc.EndBlock(providerChain, func() {})
// Get ready to update clients.
simibc.BeginBlock(providerChain, 5)
@@ -404,7 +406,7 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC
return path
}
-func (s *Driver) providerHeader() *tendermint.Header {
+func (s *Driver) providerHeader() *ibctmtypes.Header {
return s.coordinator.Chains["provider"].LastHeader
}
@@ -450,7 +452,7 @@ func (s *Driver) setupConsumer(
consumerChain := newChain(s.t, params, s.coordinator, icstestingutils.ConsumerAppIniter(initValUpdates), chain, valSet, signers, nodes, valNames)
s.coordinator.Chains[chain] = consumerChain
- path := s.ConfigureNewPath(consumerChain, providerChain, params, s.providerHeader())
+ path := s.ConfigureNewPath(consumerChain, providerChain, params)
s.simibcs[ChainId(chain)] = simibc.MakeRelayedPath(s.t, path)
}
@@ -458,20 +460,20 @@ func createConsumerGenesis(modelParams ModelParams, providerChain *ibctesting.Te
providerConsState := providerChain.LastHeader.ConsensusState()
valUpdates := cmttypes.TM2PB.ValidatorUpdates(providerChain.Vals)
- params := ccv.NewParams(
+ params := ccvtypes.NewParams(
true,
1000, // ignore distribution
"", // ignore distribution
"", // ignore distribution
modelParams.CcvTimeout[ChainId(consumerClientState.ChainId)],
- ccv.DefaultTransferTimeoutPeriod,
- ccv.DefaultConsumerRedistributeFrac,
- ccv.DefaultHistoricalEntries,
+ ccvtypes.DefaultTransferTimeoutPeriod,
+ ccvtypes.DefaultConsumerRedistributeFrac,
+ ccvtypes.DefaultHistoricalEntries,
modelParams.UnbondingPeriodPerChain[ChainId(consumerClientState.ChainId)],
"0", // disable soft opt-out
[]string{},
[]string{},
- ccv.DefaultRetryDelayPeriod,
+ ccvtypes.DefaultRetryDelayPeriod,
)
return consumertypes.NewInitialGenesisState(consumerClientState, providerConsState, valUpdates, params)
diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go
index 4b108e8120..11d6c2d817 100644
--- a/testutil/ibc_testing/generic_setup.go
+++ b/testutil/ibc_testing/generic_setup.go
@@ -7,6 +7,7 @@ import (
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
+ "github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -88,7 +89,8 @@ func AddDemocracyConsumer[T testutil.DemocConsumerApp](
s.T().Helper()
// generate validators private/public key
- valSet, valUpdates, signers := testutil.CreateValidators(s.T(), 4)
+ valSet, valUpdates, signers, err := testutil.CreateValidators(4)
+ require.NoError(s.T(), err)
ibctesting.DefaultTestingAppInit = appIniter(valUpdates)
democConsumer := ibctesting.NewTestChainWithValSet(s.T(), coordinator, democConsumerChainID, valSet, signers)
diff --git a/testutil/integration/validators.go b/testutil/integration/validators.go
index c8d2decadc..2fca9e5390 100644
--- a/testutil/integration/validators.go
+++ b/testutil/integration/validators.go
@@ -1,10 +1,6 @@
package integration
import (
- "testing"
-
- "github.com/stretchr/testify/require"
-
"github.com/cosmos/cosmos-sdk/testutil/mock"
"github.com/cometbft/cometbft/abci/types"
@@ -12,10 +8,9 @@ import (
tmtypes "github.com/cometbft/cometbft/types"
)
-func CreateValidators(t *testing.T, n int) (
- *tmtypes.ValidatorSet, []types.ValidatorUpdate, map[string]tmtypes.PrivValidator,
+func CreateValidators(n int) (
+ *tmtypes.ValidatorSet, []types.ValidatorUpdate, map[string]tmtypes.PrivValidator, error,
) {
- t.Helper()
// generate validators private/public key
var (
validators []*tmtypes.Validator
@@ -24,7 +19,9 @@ func CreateValidators(t *testing.T, n int) (
for i := 0; i < n; i++ {
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey()
- require.NoError(t, err)
+ if err != nil {
+ return nil, nil, nil, err
+ }
val := tmtypes.NewValidator(pubKey, 1)
validators = append(validators, val)
signersByAddress[pubKey.Address().String()] = privVal
@@ -33,18 +30,20 @@ func CreateValidators(t *testing.T, n int) (
// Note that the validators are sorted by voting power
// or, if equal, by address lexical order
valSet := tmtypes.NewValidatorSet(validators)
- return valSet, ToValidatorUpdates(t, valSet), signersByAddress
+ valUpdates, err := ToValidatorUpdates(valSet)
+ return valSet, valUpdates, signersByAddress, err
}
-func ToValidatorUpdates(t *testing.T, valSet *tmtypes.ValidatorSet) (valUpdates []types.ValidatorUpdate) {
- t.Helper()
+func ToValidatorUpdates(valSet *tmtypes.ValidatorSet) (valUpdates []types.ValidatorUpdate, err error) {
for _, val := range valSet.Validators {
protoPubKey, err := tmencoding.PubKeyToProto(val.PubKey)
- require.NoError(t, err)
valUpdates = append(valUpdates, types.ValidatorUpdate{
PubKey: protoPubKey,
Power: val.VotingPower,
})
+ if err != nil {
+ return nil, err
+ }
}
- return
+ return valUpdates, nil
}
diff --git a/x/ccv/provider/types/proposal_test.go b/x/ccv/provider/types/proposal_test.go
index 532831b0a6..35642c3d6a 100644
--- a/x/ccv/provider/types/proposal_test.go
+++ b/x/ccv/provider/types/proposal_test.go
@@ -7,7 +7,7 @@ import (
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
- "github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/proto"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"