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 flaky TestEmptyTableTest #433

Merged

Conversation

aarshkshah1992
Copy link
Contributor

@aarshkshah1992 aarshkshah1992 commented Dec 20, 2019

For #426

@Stebalien Please review.

Proof

GO111MODULE=on go test -count 500 -run TestEmptyTable
PASS
ok  	github.com/libp2p/go-libp2p-kad-dht	36.979s

There is nothing that will prevent all the peers from being added to the RT if the stars/randomly generated hostID cpl's align. We should remove one peer from the RT so that not all peers end up getting disconnected.

@@ -805,7 +805,7 @@ func TestEmptyTable(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

nDHTs := 50 // needs more than 40 peers so we don't add all of them to our routing table.
Copy link
Contributor Author

@aarshkshah1992 aarshkshah1992 Dec 20, 2019

Choose a reason for hiding this comment

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

@Stebalien Why did we assume here that not all peers will get added to the RT ?

Copy link
Member

Choose a reason for hiding this comment

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

I can't remember but I was probably thinking something along the lines of: Given 50 peers, about half of them will differ in the first bit. That means we'll have 25 candidates for the first bucket, leaving 5 peers out.

But there's still a high probability that this won't be the case.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Thanks! This looks like the right fix.

@@ -805,7 +805,7 @@ func TestEmptyTable(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

nDHTs := 50 // needs more than 40 peers so we don't add all of them to our routing table.
Copy link
Member

Choose a reason for hiding this comment

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

I can't remember but I was probably thinking something along the lines of: Given 50 peers, about half of them will differ in the first bit. That means we'll have 25 candidates for the first bucket, leaving 5 peers out.

But there's still a high probability that this won't be the case.

@Stebalien Stebalien merged commit 6c4cd42 into libp2p:master Dec 20, 2019
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