Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Aug 28, 2024
1 parent adaef80 commit a9b39dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
11 changes: 8 additions & 3 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu

// GetConsumerChain returns a Chain data structure with all the necessary fields
func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chain, error) {
chainID, err := k.GetConsumerChainId(ctx, consumerId)
if err != nil {
return types.Chain{}, fmt.Errorf("cannot find chainID for consumer (%s)", consumerId)
}

clientID, found := k.GetConsumerClientId(ctx, consumerId)
if !found {
return types.Chain{}, fmt.Errorf("cannot find clientID for consumer (%s)", consumerId)
Expand Down Expand Up @@ -95,12 +100,12 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai
strDenylist[i] = addr.String()
}

allowInactiveVals := k.AllowsInactiveValidators(ctx, chainID)
allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId)

minStake, _ := k.GetMinStake(ctx, chainID)
minStake := k.GetMinStake(ctx, consumerId)

return types.Chain{
ChainId: consumerId,
ChainId: chainID,
ClientId: clientID,
Top_N: topN,
MinPowerInTop_N: minPowerInTopN,
Expand Down
23 changes: 13 additions & 10 deletions x/ccv/provider/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ func TestGetConsumerChain(t *testing.T) {
pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

consumerIDs := []string{"1", "23", "345", "6789"}

chainIDs := []string{"chain-1", "chain-2", "chain-3", "chain-4"}

// mock the validator set
Expand Down Expand Up @@ -433,23 +435,24 @@ func TestGetConsumerChain(t *testing.T) {
}

expectedGetAllOrder := []types.Chain{}
for i, chainID := range chainIDs {
clientID := fmt.Sprintf("client-%d", len(chainIDs)-i)
for i, consumerID := range consumerIDs {
pk.SetConsumerChainId(ctx, consumerID, chainIDs[i])
clientID := fmt.Sprintf("client-%d", len(consumerID)-i)
topN := topNs[i]
pk.SetConsumerClientId(ctx, chainID, clientID)
pk.SetConsumerPowerShapingParameters(ctx, chainID, types.PowerShapingParameters{
pk.SetConsumerClientId(ctx, consumerID, clientID)
pk.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{
Top_N: topN,
ValidatorSetCap: validatorSetCaps[i],
ValidatorsPowerCap: validatorPowerCaps[i],
AllowInactiveVals: allowInactiveVals[i],
MinStake: minStakes[i].Uint64(),
})
pk.SetMinimumPowerInTopN(ctx, chainID, expectedMinPowerInTopNs[i])
pk.SetInactiveValidatorsAllowed(ctx, chainID, allowInactiveVals[i])
pk.SetMinStake(ctx, chainID, minStakes[i].Uint64())
pk.SetMinimumPowerInTopN(ctx, consumerID, expectedMinPowerInTopNs[i])
for _, addr := range allowlists[i] {
pk.SetAllowlist(ctx, chainID, addr)
pk.SetAllowlist(ctx, consumerID, addr)
}
for _, addr := range denylists[i] {
pk.SetDenylist(ctx, chainID, addr)
pk.SetDenylist(ctx, consumerID, addr)
}
strAllowlist := make([]string, len(allowlists[i]))
for j, addr := range allowlists[i] {
Expand All @@ -463,7 +466,7 @@ func TestGetConsumerChain(t *testing.T) {

expectedGetAllOrder = append(expectedGetAllOrder,
types.Chain{
ChainId: chainID,
ChainId: chainIDs[i],
ClientId: clientID,
Top_N: topN,
MinPowerInTop_N: expectedMinPowerInTopNs[i],
Expand Down

0 comments on commit a9b39dd

Please sign in to comment.