Skip to content

Commit

Permalink
cover stopped phase case
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Aug 26, 2024
1 parent ad5288d commit fca239b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,8 @@ func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryC
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

// if the consumer hasn't launched yet, compute the consumer validator set
} else {
// if the consumer hasn't been launched being stopped, compute the consumer validator set
} else if phase != Stopped {
bondedValidators, err := k.GetLastBondedValidators(ctx)
if err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("failed to get last validators: %s", err))
Expand Down
7 changes: 7 additions & 0 deletions x/ccv/provider/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ func TestQueryConsumerValidators(t *testing.T) {
res, err = pk.QueryConsumerValidators(ctx, &req)
require.NoError(t, err)
require.Equal(t, val1.Commission.Rate, res.Validators[0].ConsumerCommissionRate)

// set consumer to stopped phase
pk.SetConsumerPhase(ctx, consumerId, keeper.Stopped)
// expect empty valset
res, err = pk.QueryConsumerValidators(ctx, &req)
require.NoError(t, err)
require.Empty(t, res)
}

func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) {
Expand Down

0 comments on commit fca239b

Please sign in to comment.