Skip to content

Commit

Permalink
provider: fix throttle and relay tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Mar 3, 2024
1 parent ab3637e commit 991bf8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions x/ccv/provider/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"strings"
"testing"

"cosmossdk.io/math"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"cosmossdk.io/math"

cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down Expand Up @@ -148,7 +147,11 @@ func TestOnRecvDowntimeSlashPacket(t *testing.T) {
providerAddr := providertypes.NewProviderConsAddress(packetData.Validator.Address)
calls := []*gomock.Call{
mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()).
Return(stakingtypes.Validator{}, nil).Times(1),
Return(stakingtypes.Validator{
// must be a hex string so it can be properly decoded by sdktypes.ValAddressFromHex(val.GetOperator())
// empty string is fine, as it's not used in this test
OperatorAddress: "557D5BD0FA991DAB8EED2B9DCF98AC1B3200D43D",
}, nil).Times(1),
mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(ctx, gomock.Any()).
Return(int64(2), nil).Times(1),
}
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context,
} else {
// Otherwise, return the staking keeper's LastValidatorPower value.
// NOTE: @MSalopek double check this conversion and see if it's necessary
valAddrBech32, err := sdktypes.ValAddressFromHex(val.GetOperator())
valAddr, err := sdktypes.ValAddressFromHex(val.GetOperator())
if err != nil {
return math.ZeroInt()
}

power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddrBech32)
power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr)
if err != nil {
return math.ZeroInt()
}
Expand Down

0 comments on commit 991bf8e

Please sign in to comment.