Skip to content

Commit

Permalink
fix: fixed QueryAllPairsValConAddrByConsumerChainID output formatting (
Browse files Browse the repository at this point in the history
…#1722)

* fix: fixed QueryAllPairsValConAddrByConsumerChainID output formatting

* fix: name PairValConAddrProviderAndConsumer more appropriately

* chore: fixed tests
  • Loading branch information
freak12techno authored Apr 15, 2024
1 parent 013235d commit b0c0df9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ message QueryAllPairsValConAddrByConsumerChainIDResponse {

message PairValConAddrProviderAndConsumer {
// The consensus address of the validator on the provider chain
string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"provider_address\"" ];
// The consensus address of the validator on the consumer chain
string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"consumer_address\"" ];
tendermint.crypto.PublicKey consumer_key = 3;
}

Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context,
return nil, err
}
pairValConAddrs = append(pairValConAddrs, &types.PairValConAddrProviderAndConsumer{
ProviderAddress: string(data.ProviderAddr),
ConsumerAddress: string(consumerAddr),
ProviderAddress: sdk.ConsAddress(data.ProviderAddr).String(),
ConsumerAddress: consumerAddr.String(),
ConsumerKey: data.ConsumerKey,
})
}
Expand Down
10 changes: 7 additions & 3 deletions x/ccv/provider/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/stretchr/testify/require"

sdktypes "github.com/cosmos/cosmos-sdk/types"
cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto"
testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper"
"github.com/cosmos/interchain-security/v4/x/ccv/provider/types"
Expand All @@ -14,7 +15,10 @@ import (

func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) {
chainID := consumer
providerAddr := types.NewProviderConsAddress([]byte("providerAddr"))

providerConsAddress, err := sdktypes.ConsAddressFromBech32("cosmosvalcons1wpex7anfv3jhystyv3eq20r35a")
require.NoError(t, err)
providerAddr := types.NewProviderConsAddress(providerConsAddress)

consumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey()
consumerAddr, err := ccvtypes.TMCryptoPublicKeyToConsAddr(consumerKey)
Expand Down Expand Up @@ -48,8 +52,8 @@ func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) {
require.NoError(t, err)

expectedResult := types.PairValConAddrProviderAndConsumer{
ProviderAddress: "providerAddr",
ConsumerAddress: string(consumerAddr),
ProviderAddress: providerConsAddress.String(),
ConsumerAddress: consumerAddr.String(),
ConsumerKey: &consumerKey,
}
require.Equal(t, &consumerKey, response.PairValConAddr[0].ConsumerKey)
Expand Down

0 comments on commit b0c0df9

Please sign in to comment.