Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Fedekunze/1939 tests for staking lcd #2000

Merged
merged 8 commits into from
Aug 13, 2018

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Aug 13, 2018

Closes #1939

Staking endpoints now support:

  • GET /stake/delegators/{delegatorAddr}/validators

  • GET /stake/delegators/{delegatorAddr}/validators/{validatorAddr}

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Updated all relevant documentation (docs/)

  • Updated all relevant code comments

  • Wrote tests

  • Added entries in PENDING.md that include links to the relevant issue or PR that most accurately describes the change.

  • Updated cmd/gaia and examples/


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Federico Kunze added 2 commits August 13, 2018 14:52
@codecov
Copy link

codecov bot commented Aug 13, 2018

Codecov Report

Merging #2000 into develop will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop    #2000   +/-   ##
========================================
  Coverage    64.86%   64.86%           
========================================
  Files          115      115           
  Lines         6862     6862           
========================================
  Hits          4451     4451           
  Misses        2127     2127           
  Partials       284      284

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fedekunze ! I left a few minor remarks, but otherwise LGTM 👍

@@ -409,40 +410,69 @@ func TestBonding(t *testing.T) {
bond := getDelegation(t, port, addr, validator1Owner)
require.Equal(t, "60.0000000000", bond.Shares)

// query summary
summary := getDelegationSummary(t, port, addr)
assert.Len(t, summary.Delegations, 1, "Delegation summary holds all delegations")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is we use require's I believe 👍

// check if tx was committed
require.Equal(t, uint32(0), resultTx.CheckTx.Code)
require.Equal(t, uint32(0), resultTx.DeliverTx.Code)

// // query validator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove any unnecessary commented out code.

assert.Len(t, unbondings, 1, "Unbondings holds all unbonding-delegations")
assert.Equal(t, "30", unbondings[0].Balance.Amount.String())
assert.Equal(t, "60", unbondings[0].Balance.Amount.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

bondedValidators = getDelegatorValidators(t, port, addr)
require.Len(t, bondedValidators, 0)

// resultTx = doBeginUnbonding(t, port, seed, name, password, addr, validator1Owner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

var bondedValidators []stake.BechValidator
err := cdc.UnmarshalJSON([]byte(body), &bondedValidators)
require.Nil(t, err)
fmt.Println(fmt.Sprintf("–––> DelegatorVals: %v", bondedValidators))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these print statements?

func doDelegate(t *testing.T, port, seed, name, password string, delegatorAddr, validatorAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
func getDelegatorValidators(t *testing.T, port string, delegatorAddr sdk.AccAddress) []stake.BechValidator {

var res *http.Response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we improve the spacing a bit to help the legibility?


func getDelegatorValidator(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress) stake.BechValidator {

var res *http.Response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -32,6 +32,18 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *wire.Cod
delegatorTxsHandlerFn(cliCtx, cdc),
).Methods("GET")

// GET /stake/delegators/{delegatorAddr}/validators // Query all validators that a delegator is bonded to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need the comments // GET /stake/delegators/{delegatorAddr}/validators/{validatorAddr} and the other? It seems the code documents that enough? The other comments are good 👍

@fedekunze
Copy link
Collaborator Author

@alexanderbez Addressed comments !

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM. Thanks @fedekunze 👍

@fedekunze fedekunze mentioned this pull request Aug 13, 2018
6 tasks
Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good - thanks!

@rigelrozanski rigelrozanski merged commit 63713c9 into develop Aug 13, 2018
@rigelrozanski rigelrozanski deleted the fedekunze/1939-tests-for-staking-lcd branch August 13, 2018 22:06
fedekunze added a commit that referenced this pull request Aug 15, 2018
* Added tests for Delegator Validators routes

* Updated tests for undelegations

* Updated Gaia-lite docs

* Updated PENDING.md

* Updated comments

* Deleted more comments

* Add spacing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants