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

Fix memory leak #979

Merged
merged 7 commits into from
Nov 19, 2018
Merged

Conversation

skhoroshavin
Copy link
Member

No description provided.

Sergey Khoroshavin added 3 commits November 15, 2018 17:41
Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>
Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>
Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>

def __contains__(self, item):
view_no, pp_seq_no = item
return pp_seq_no in self._batches[view_no]
Copy link
Contributor

Choose a reason for hiding this comment

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

What if viewno is not in self._batches?

Copy link
Member Author

Choose a reason for hiding this comment

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

Then empty IntervalList will be returned, since self._batches is defaultdict(IntervalList). So, nothing bad here

Copy link
Member Author

Choose a reason for hiding this comment

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

assert 3 not in intervals


def test_interval_list_can_have_multiple_blocks(intervals: IntervalList):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add more tests:

  • add the same value multiple times
  • add more tests for adding in different order, for example:
    -- 2,1,4,3
    -- 1,2,4,5,6,3

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually such cases are covered by a bit higher level randomized tests of OrderedTracker

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, it might be beneficial to employ Hypothesis framework (https://hypothesis.readthedocs.io/en/latest/) here.

Sergey Khoroshavin added 4 commits November 15, 2018 19:31
…d tests

Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>
Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>
Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>
Signed-off-by: Sergey Khoroshavin <sergey.khoroshavin@dsr-corporation.com>
return

for prev, next in zip(self._intervals, self._intervals[1:]):
if item == prev[1] + 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to have deterministic unit test for every if-else in add method

@@ -92,6 +92,89 @@ def handleSync(self, msg: Any) -> Any:
self.replica.node.reportSuspiciousNodeEx(ex)


class IntervalList:
Copy link
Contributor

Choose a reason for hiding this comment

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

Cab we use IntervalTree (we already have this dependency) instead?

@ashcherbakov ashcherbakov merged commit b5b73ca into hyperledger:master Nov 19, 2018
@skhoroshavin skhoroshavin deleted the ordered-tracker branch November 19, 2018 09:38
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.

None yet

2 participants