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

add more test for recordRate rate-controller #1627

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tunedev
Copy link
Contributor

@tunedev tunedev commented Sep 11, 2024

Checklist

  • A link to the issue/user story that the pull request relates to
  • How to recreate the problem without the fix
  • Design of the fix
  • How to prove that the fix works
  • Automated tests that prove the fix keeps on working
  • Documentation - any JSDoc, website, or Stackoverflow answers?

Issue/User story

Partially addresses #1606

Steps to Reproduce

Existing issues

Design of the fix

Validation of the fix

After this PR: Running the tests in caliper-core the listed %stmts in the code coverage report should tally with the below listed

  • caliper-core/lib/worker/recordRate.js: 95.52

Before the PR: Running the tests in caliper-core the listed %stmts in the code coverage report the below listed was what was there before

  • caliper-core/lib/worker/recordRate.js: 43.28

What documentation has been provided for this pull request

@tunedev tunedev requested a review from a team September 11, 2024 06:59
Copy link
Contributor

@davidkel davidkel left a comment

Choose a reason for hiding this comment

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

Sorry lots of issues with this test I'm afraid

Copy link
Contributor

@davidkel davidkel left a comment

Choose a reason for hiding this comment

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

There appear to be more changes required for this based on previous comments.

@tunedev tunedev force-pushed the add-more-test-for-recordRate branch 2 times, most recently from 249bc61 to 7e89b68 Compare November 11, 2024 07:46
@tunedev
Copy link
Contributor Author

tunedev commented Nov 11, 2024

There appear to be more changes required for this based on previous comments.

@davidkel i have tended to them, thanks

Copy link
Contributor

@davidkel davidkel left a comment

Choose a reason for hiding this comment

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

So more issues here I'm afraid, but the sparse population of the records array has shown up bugs but unfortunately you hid by fixing the test, so something to always bare in mind.
On further thought as well for completeness we should also add tests that test records that are not sparse. ie we have continuous values starting at the 0'th record element (eg records[0]=100;records[1]=300;records[2]=500;records[3]=700;) as this is a common scenario as well. So we should have tests for it.


const controller = RecordRate.createRateController(testMessage, stubStatsCollector, 0);

controller.records.should.be.an('array').that.has.lengthOf(5);
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is not correct, as stated in a previous review, the value here should be one more than the value returned by getNumberOfTxs because we can and probably will have an entry for 0 transactions submitted therefore if we have 5 transactions submitted then we would have 0-5 possible records. This will then show there is a bug in the code which needs to be fixed.

Signed-off-by: Babatunde Sanusi <swisskid95@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants