-
Notifications
You must be signed in to change notification settings - Fork 92
[FEATURE] Balances|Trustlines|Orders: Return ledger_index, use last validated ledger by default (RLJS-127) #230
[FEATURE] Balances|Trustlines|Orders: Return ledger_index, use last validated ledger by default (RLJS-127) #230
Conversation
@@ -77,7 +79,7 @@ function getBalances(request, response, next) { | |||
var accountLinesRequest; | |||
var marker = request.query.marker; | |||
var limit = /^[0-9]*$/.test(request.query.limit) ? Number(request.query.limit) : void(0); | |||
var ledger = /^[0-9]*$/.test(request.query.ledger) ? Number(request.query.ledger) : void(0); | |||
var ledger = /^[0-9]*$/.test(request.query.ledger) ? Number(request.query.ledger) : 'validated'; |
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.
> /^[0-9]*$/.test('') ? Number('') : 'validated'
0
Might want to make it [0-9]+ or Just test !isNaN
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.
That looks like a bug? I can make that change a separate PR
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.
Why not include it here?
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 can do that as well! I'm still figuring out what the dev practices are for ripple-rest/lib. (Aside: That's technically a change in implementation unrelated to this PR. In my past experience, keeping commits atomic made reverting changes easier if they introduced additional bugs)
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 would make it work as expected, [0-9]* isn't a good number test. This [FEATURE] doesn't seem complete without a reasonable is-number test.
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'd prefer hiding the implementation details in a function, which can be unit tested. That validator
snippet above looks good to me. I'll see if that works
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.
Does this look like correct behavior?
> validator.isValid('', 'UINT32')
true
> validator.isValid('f', 'UINT32')
false
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.
Apparently that ain't no good neither
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.
Is it possible that the regex is incorrect?
In the schema file for UINT32:
^$|^(429496729[0-5]|42949672[0-8][0-
That first case is checking for an empty string. @emschwartz do you remember where that schema came from? It comes from cd45dd7
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.
218bc0d
to
017da26
Compare
LGTM |
Hold off on merging, I'm going to add this to Orders as welll |
Squash please |
I was going to squash after review |
LGTM |
172820b
to
065f30a
Compare
Squashed |
conn.send(fixtures.accountLinesResponse(message, { | ||
marker: NEXT_MARKER, | ||
validated: false | ||
})); |
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.
Not passing in ledger to response
There's also a bug I need to address in a followup:
The rippled response looks like it's querying against the currently (non-validated) open ledger |
@@ -74,9 +77,10 @@ suite('get trustlines', function() { | |||
}); | |||
|
|||
self.wss.once('request_account_lines', function(message, conn) { | |||
console.log(message); |
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.
remove this console.log
de4dcc7
to
992dd76
Compare
Updated |
992dd76
to
5fa3eb6
Compare
rebased |
.expect(testutils.checkBody(fixtures.RESTAccountBalancesXRPResponse)) | ||
.expect(testutils.checkBody(fixtures.RESTAccountBalancesXRPResponse({ | ||
ledger: LEDGER, | ||
validated: true |
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.
don't need validated: true
here as it is a default
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.
Noted. I'll check the other tests
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.
Fixed
5fa3eb6
to
7d7a8e7
Compare
OK. LGTM, good work @LumberJ |
_.defaults(options, { | ||
account: addresses.VALID |
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.
Forgot about this guy
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.
Fixed
[FEATURE] Balances|Trustlines: Return ledger index (RLJS-127) [FEATURE] Balances|Trustlines: Use last validated ledger by default [FEATURE] Balances|Trustlines: Return ledger validated in response Returns validated (boolean) if the ledger_index returned is validated or not [TASK] Balances|Trustlines: Check limit and ledger are valid uint32 and not empty string [FEATURE] Orders: Return ledger_index, default to last validated [TEST] Orders|Balances|Trustlines: Refactor some of the tests [BUG] Balances: Return XRP balance based on last validated ledger Also address some comments on PR [TASK] Trustlines: Remove extra tests, PR comments addressed [TASK] Orders: Removed unneccesary tests, responding to PR comments
7d7a8e7
to
9bdb0cc
Compare
[FEATURE] Balances|Trustlines|Orders: Return ledger_index, use last validated ledger by default (RLJS-127)
Also, returns
validated
key as a boolean (from the rippled response)