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

p2p/discover: fix bug in checkNodesEqual #29603

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions p2p/discover/table_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ func checkNodesEqual(got, want []*enode.Node) error {
goto NotEqual
}
}
} else {
return fmt.Errorf("length dismatch: got %d nodes, want %d nodes", len(got), len(want))
Comment on lines +244 to +245
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternative fix: just move the return nil up one line, into the if-clause. Then the non-equal case would just fall through to the code below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@holiman Thanks for reviewing. What you suggest seems more elegant :)

But what more important is that test case TestUDPv5_lookupE2E is defective, UDPv5.Lookup actually could not find all expected nodes. So if we merge this bugfix, this test case will never pass.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, well done then finding a bug in the testcase!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@holiman I try to fix TestUDPv5_lookupE2E, but it seem hard for me now :)

Maybe you guys could fix it, then this PR could get merged.

}
return nil

Expand Down
2 changes: 1 addition & 1 deletion p2p/discover/v5_udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func startLocalhostV5(t *testing.T, cfg Config) *UDPv5 {
}
realaddr := socket.LocalAddr().(*net.UDPAddr)
ln.SetStaticIP(realaddr.IP)
ln.Set(enr.UDP(realaddr.Port))
ln.SetFallbackUDP(realaddr.Port)
udp, err := ListenV5(socket, ln, cfg)
if err != nil {
t.Fatal(err)
Expand Down