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

Kademlia EachBin bug fix and unit tests #18338

Closed
wants to merge 8 commits into from

Conversation

holisticode
Copy link
Contributor

@holisticode holisticode commented Dec 19, 2018

This PR adds a unit test for the kademlia.EachBin function.

This function is responsible for the correct registration of syncing subscriptions for the stream protocol.

Apart from fixing a couple of bugs, most importantly this PR introduces a unit test.
ethersphere/swarm#1071 is an issue to refactor the EachBin function; with a working unit test that refactor gets a test-driven approach.

Replaces #18284 (which was for discussion)

@holisticode holisticode changed the title Kadeamlia EachBin bug fix and unit tests Kademlia EachBin bug fix and unit tests Dec 19, 2018
@nolash nolash requested a review from gluk256 December 19, 2018 17:25
Copy link
Contributor

@zelig zelig left a comment

Choose a reason for hiding this comment

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

pending on merge of new depth calculation otherwise chunks in bins with no peers (empty bins shallower than depth) will NOT be synced

if startPo > 0 && endPo != k.MaxProxDisplay {
startPo = endPo + 1
}
//if the peer's bin is smaller than the kademlia depth,
Copy link
Contributor

Choose a reason for hiding this comment

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

but now this PR really needs to wait for the new depth calculation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed

Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not use "smaller". Please review the terminology introduced here:

ethersphere/swarm#1051

If you don't agree with the terms, let's discuss and settle on something everyone can agree with.

Copy link
Contributor

@nolash nolash left a comment

Choose a reason for hiding this comment

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

Shouldn't this be PR'd to ethersphere instead?

//EachBin iterates over each connection of a kademlia table, per bin.
//So `po` will be representing the bin value (0..255), while `val` represents an
//existing connection inside that bin.
//For any such connection found, the parameter func `eachBinFunc` will be executed
Copy link
Contributor

Choose a reason for hiding this comment

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

if startPo > 0 && endPo != k.MaxProxDisplay {
startPo = endPo + 1
}
//if the peer's bin is smaller than the kademlia depth,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not use "smaller". Please review the terminology introduced here:

ethersphere/swarm#1051

If you don't agree with the terms, let's discuss and settle on something everyone can agree with.

015 0 | 0
=========================================================================
*/
func TestEachBin(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A unit test should not be opinionated about the context which it's used by consumers. I find the terms "subscription" etc wholly out of place here. Keep it minimal to the exact expectations of what this function should provide and nothing more.

Copy link
Contributor

Choose a reason for hiding this comment

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

But since that is the point of the test not the iterator (despite the name of the PR), the test should be in the stream package rather than here.

@holisticode
Copy link
Contributor Author

has been obsoleted by #18355

@frncmx frncmx deleted the kad-eachbin-fix branch January 22, 2019 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants