Skip to content

Commit

Permalink
removed redelegation stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Nov 4, 2018
1 parent f8b030a commit eeff820
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
29 changes: 0 additions & 29 deletions x/stake/querier/queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const (
QueryDelegator = "delegator"
QueryDelegation = "delegation"
QueryUnbondingDelegation = "unbondingDelegation"
QueryRedelegation = "redelegation"
QueryDelegatorValidators = "delegatorValidators"
QueryDelegatorValidator = "delegatorValidator"
QueryPool = "pool"
Expand Down Expand Up @@ -93,14 +92,6 @@ type QueryBondsParams struct {
ValidatorAddr sdk.ValAddress
}

// defines the params for the following queries:
// - 'custom/stake/redelegation'
type QueryRedelegationParams struct {
DelegatorAddr sdk.AccAddress
SrcValidatorAddr sdk.ValAddress
DstValidatorAddr sdk.ValAddress
}

func queryValidators(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) {
stakeParams := k.GetParams(ctx)
validators := k.GetValidators(ctx, stakeParams.MaxValidators)
Expand Down Expand Up @@ -313,26 +304,6 @@ func queryUnbondingDelegation(ctx sdk.Context, cdc *codec.Codec, req abci.Reques
return res, nil
}

func queryRedelegation(ctx sdk.Context, cdc *codec.Codec, req abci.RequestQuery, k keep.Keeper) (res []byte, err sdk.Error) {
var params QueryRedelegationParams

errRes := cdc.UnmarshalJSON(req.Data, &params)
if errRes != nil {
return []byte{}, sdk.ErrUnknownRequest(string(req.Data))
}

redel, found := k.GetRedelegation(ctx, params.DelegatorAddr, params.SrcValidatorAddr, params.DstValidatorAddr)
if !found {
return []byte{}, types.ErrNoRedelegation(types.DefaultCodespace)
}

res, errRes = codec.MarshalJSONIndent(cdc, redel)
if errRes != nil {
return nil, sdk.ErrInternal(sdk.AppendMsgToErr("could not marshal result to JSON", errRes.Error()))
}
return res, nil
}

func queryPool(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) {
pool := k.GetPool(ctx)

Expand Down
29 changes: 0 additions & 29 deletions x/stake/querier/queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ func newTestBondQuery(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress
}
}

func newTestRedelegationQuery(delegatorAddr sdk.AccAddress, srcValidatorAddr sdk.ValAddress, dstValidatorAddr sdk.ValAddress) QueryRedelegationParams {
return QueryRedelegationParams{
DelegatorAddr: delegatorAddr,
SrcValidatorAddr: srcValidatorAddr,
DstValidatorAddr: dstValidatorAddr,
}
}

func TestNewQuerier(t *testing.T) {
cdc := codec.New()
ctx, _, keeper := keep.CreateTestInput(t, false, 1000)
Expand Down Expand Up @@ -373,27 +365,6 @@ func TestQueryDelegation(t *testing.T) {

_, err = queryDelegatorUnbondingDelegations(ctx, cdc, query, keeper)
require.NotNil(t, err)

// Query redelegation
redel, err := keeper.BeginRedelegation(ctx, addrAcc2, val1.OperatorAddr, val2.OperatorAddr, sdk.NewDec(10))
require.Nil(t, err)

bz, errRes = cdc.MarshalJSON(newTestRedelegationQuery(addrAcc2, val1.OperatorAddr, val2.OperatorAddr))
require.Nil(t, errRes)

query = abci.RequestQuery{
Path: "/custom/stake/redelegation",
Data: bz,
}

res, err = queryRedelegation(ctx, cdc, query, keeper)
require.Nil(t, err)

var redelRes types.Redelegation
errRes = cdc.UnmarshalJSON(res, &redelRes)
require.Nil(t, errRes)

require.Equal(t, redel, redelRes)
}

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

0 comments on commit eeff820

Please sign in to comment.