-
Notifications
You must be signed in to change notification settings - Fork 110
swarm/network, swarm/pss, p2p/simulations: adapt test kademlia params #1022
Conversation
… to correctly check node reachability
977f5f9
to
718622b
Compare
718622b
to
6ba7436
Compare
ab51d7e
to
9ca145f
Compare
otherwise LGTM |
@zelig that did it. now, I understand that conceptually this if statement should be in the discovery test (i had a weird feeling seeing it there in the first place). what I don't get is why it was failing. |
@justelad should 'unskipping' those simulation tests that use |
conn.Up = false | ||
conn.initiated = time.Now().Add(-DialBanTimeout) | ||
conn.wasInitiated = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it now correct to "allow" disconnection of a disconnected node?
if err != nil { | ||
log.Trace("net.InitConn returned an error", "err", err) | ||
r := rand.New(rand.NewSource(time.Now().UnixNano())) | ||
t := time.Duration(time.Duration(r.Intn(200)) * time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read this as skewing of time offsets in case nodes try to connect simultaneously? Is this actually a solution to the problem?
default: | ||
r := rand.New(rand.NewSource(time.Now().Unix())) | ||
timeToSleep := time.Duration(200 + int64(r.Intn(200))) | ||
time.Sleep(timeToSleep * time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a parameter not literal 200
?
copy(enode[:], e.BzzAddr.Over()) | ||
if !k.Reachable(enode) { | ||
r := rand.New(rand.NewSource(time.Now().UnixNano())) | ||
t := time.Duration(time.Duration(r.Intn(400)) * time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about all these literals, amigo...
This PR addresses an incorrect node setup on certain simulations, in which the
Reachable
function in the Kademlia was not called at all. This resulted in tests flaking due to peer dialups not being sanctioned correctly.Similar tests that use
ServiceContext
on setup have been amended to correctly reference the correctReachable
function pointer from theServiceContext
.fixes #994