-
Notifications
You must be signed in to change notification settings - Fork 499
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
clients/horizonclient: fix multi-parameter url for claimable balance query #4248
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e681b94
bugfix: 4247 - claimable balance - check if one of the parameters is ID
iateadonut 758d6b3
Merge branch 'master' of https://github.com/stellar/go into 4247/clai…
iateadonut a7e2313
Merge branch 'master' into 4247/claimable_balance
iateadonut 4cec1fb
Merge branch '4247/claimable_balance' of github.com:iateadonut/go int…
iateadonut 3d84568
clients/horizonclient: cursor and limit in ClaimableBalanceRequest
iateadonut c64d693
Merge branch 'master' into 4247/claimable_balance
iateadonut dfb520f
clients/horizonclient: cursor and limit in ClaimableBalanceRequest te…
iateadonut 96a920f
Merge branch '4247/claimable_balance' of github.com:iateadonut/go int…
iateadonut a0be92d
Merge branch 'master' into 4247/claimable_balance
iateadonut 2343187
clients/horizonclient: cursor and limit in ClaimableBalanceRequest - …
iateadonut c3ed6b2
Merge branch '4247/claimable_balance' of github.com:iateadonut/go int…
iateadonut 3f4f3e7
Merge branch 'master' into 4247/claimable_balance
Shaptic 9ac8dde
add test for limit; move cursor and limit out of params
iateadonut d54270a
Merge branch '4247/claimable_balance' of github.com:iateadonut/go int…
iateadonut 4d0b6f0
claimable balance request: do not allow a limit of more than 200
iateadonut c10e167
Merge branch 'master' into 4247/claimable_balance
Shaptic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package horizonclient | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestClaimableBalanceBuildUrl(t *testing.T) { | ||
|
||
cbr := ClaimableBalanceRequest{ | ||
ID: "1235", | ||
} | ||
url, err := cbr.BuildURL() | ||
assert.Equal(t, "claimable_balances/1235", url) | ||
assert.NoError(t, err) | ||
|
||
//if the ID is included, you cannot include another parameter | ||
cbr = ClaimableBalanceRequest{ | ||
ID: "1235", | ||
Claimant: "CLAIMANTADDRESS", | ||
} | ||
_, err = cbr.BuildURL() | ||
assert.EqualError(t, err, "invalid request: too many parameters") | ||
|
||
//if you have two parameters, and neither of them are ID, it must use both in the URL | ||
cbr = ClaimableBalanceRequest{ | ||
Claimant: "CLAIMENTADDRESS", | ||
iateadonut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Asset: "TEST:ISSUERADDRESS", | ||
} | ||
url, err = cbr.BuildURL() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "claimable_balances?asset=TEST%3AISSUERADDRESS&claimant=CLAIMENTADDRESS", url) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure this is necessary?
countParams
returns 1 if thecbr.ID
is set.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.
Yes it is necessary; you can have more than one parameter if the ID is not set.
This is valid but returns and error with no cbr.ID != "" condition:
it would query this: https://horizon.stellar.org/claimable_balances/?claimant=GDJCDWRAAB3LA6TT32OBOXV2UYVJEVPKMQXDLUWYH7FQ73MCTH3UNPT7&limit=200&asset=AQUA:GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA
see the associated test, https://github.com/stellar/go/pull/4248/files#diff-368f30ea351d73347fe7c2dac69307ae69e3cdf5f2e92f6d584e097aa256db31line 26
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.
Huh, so the comment is a lie then 🤔 can you rephrase it? Then ✔️ from my perspective 👍
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.
updated the comment to:
// You can't mix an ID query and filters.
and the error verbiage to:
return endpoint, errors.New("invalid request: you cannot have an ID query with filters")