-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
…edekunze/1939-tests-for-staking-lcd Rebase develop
Codecov Report
@@ Coverage Diff @@
## develop #2000 +/- ##
========================================
Coverage 64.86% 64.86%
========================================
Files 115 115
Lines 6862 6862
========================================
Hits 4451 4451
Misses 2127 2127
Partials 284 284 |
There was a problem hiding this 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 👍
client/lcd/lcd_test.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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 👍
client/lcd/lcd_test.go
Outdated
// check if tx was committed | ||
require.Equal(t, uint32(0), resultTx.CheckTx.Code) | ||
require.Equal(t, uint32(0), resultTx.DeliverTx.Code) | ||
|
||
// // query validator |
There was a problem hiding this comment.
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.
client/lcd/lcd_test.go
Outdated
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
client/lcd/lcd_test.go
Outdated
bondedValidators = getDelegatorValidators(t, port, addr) | ||
require.Len(t, bondedValidators, 0) | ||
|
||
// resultTx = doBeginUnbonding(t, port, seed, name, password, addr, validator1Owner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
client/lcd/lcd_test.go
Outdated
var bondedValidators []stake.BechValidator | ||
err := cdc.UnmarshalJSON([]byte(body), &bondedValidators) | ||
require.Nil(t, err) | ||
fmt.Println(fmt.Sprintf("–––> DelegatorVals: %v", bondedValidators)) |
There was a problem hiding this comment.
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?
client/lcd/lcd_test.go
Outdated
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 |
There was a problem hiding this comment.
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?
client/lcd/lcd_test.go
Outdated
|
||
func getDelegatorValidator(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress) stake.BechValidator { | ||
|
||
var res *http.Response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
x/stake/client/rest/query.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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 👍
@alexanderbez Addressed comments ! |
There was a problem hiding this 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 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good - thanks!
* Added tests for Delegator Validators routes * Updated tests for undelegations * Updated Gaia-lite docs * Updated PENDING.md * Updated comments * Deleted more comments * Add spacing
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
andexamples/
For Admin Use: