Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Add from/to timestamp filter to get blocks endpoint - Closes #2391 #2472

Merged
merged 8 commits into from
Oct 18, 2018

Conversation

diego-G
Copy link

@diego-G diego-G commented Oct 15, 2018

How to test it?

mocha test/functional/http/get/blocks.js

Review checklist

@@ -106,6 +106,16 @@ __private.list = function(filter, cb) {
params.height = filter.height;
}

if (filter.fromTimestamp >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In swagger we say 0 is the valid value. Should not we simplify it on API level to disallow zero as param value?

https://github.com/LiskHQ/lisk/blob/5acfc7bdd902965124263d448be124edf481b6ae/schema/swagger.yml#L1169-L1174

Copy link
Author

@diego-G diego-G Oct 16, 2018

Choose a reason for hiding this comment

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

The idea is to keep 0 as an allowed value. However, there was a mistake in the control of toTimestamp that I've caught thanks to this comment. @nazarhussain could you check it again? I hope now it's easier to understand.

params.fromTimestamp = filter.fromTimestamp;
}

if (filter.toTimestamp >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -112,6 +113,72 @@ describe('GET /blocks', () => {
});
});

describe('fromTimestamp', () => {
it('using too small fromTimestamp should fail', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

using invalid timestamp should fail?

});

describe('toTimestamp', () => {
it('using too small toTimestamp should fail', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

Copy link
Contributor

@nazarhussain nazarhussain left a comment

Choose a reason for hiding this comment

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

We may add validation to check if fromTimestamp is always less than toTimestamp. Its not that much needed but may be useful.

@shuse2 shuse2 merged commit ede0f27 into development Oct 18, 2018
@shuse2 shuse2 deleted the 2391-add_fromTo_timestamp_filter_get_blocks branch October 18, 2018 13:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add fromTimestamp and toTimestamp to Blocks API endpoint
6 participants