Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

bzzeth: protocol runloop now quits on peer disconnect #1745

Merged
merged 5 commits into from
Sep 14, 2019
Merged

Conversation

jmozah
Copy link
Collaborator

@jmozah jmozah commented Sep 11, 2019

fixes #1730

bzzeth/bzzeth.go Show resolved Hide resolved
bzzeth/wire.go Outdated Show resolved Hide resolved
// Wait for sometime and see if peer is connected and idling
time.Sleep(1000 * time.Millisecond)
if _, ok := b.peers.peers[node.ID()]; !ok {
t.Fatalf("peer is not connected")
Copy link
Member

Choose a reason for hiding this comment

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

This test seems flaky now:

ERROR[09-11|15:53:03.329|github.com/ethersphere/swarm/p2p/protocols/protocol.go:238] peer.handleIncoming                      err="Message handler error: (msg code 1): received message from Swarm node"
--- FAIL: TestBzzBzzHandshake (1.09s)
    bzzeth_test.go:162: peer still connected
FAIL
coverage: 46.0% of statements
FAIL	github.com/ethersphere/swarm/bzzeth	2.364s

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added some delay after sending the dummy message... It should work fine now.

Copy link
Member

Choose a reason for hiding this comment

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

I know that we are trying to avoid adding sleeps to tests. I it possible to fix flakiness with other methods?
BTW, I do not see the new delay, did you push?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed it now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sleep seems to be the option for now...

Copy link
Member

Choose a reason for hiding this comment

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

I would like to hear other opinions on using sleeps.

bzzeth/bzzeth.go Outdated Show resolved Hide resolved
bzzeth/wire.go Outdated Show resolved Hide resolved
bzzeth/wire.go Outdated Show resolved Hide resolved
bzzeth/bzzeth_test.go Outdated Show resolved Hide resolved
bzzeth/bzzeth_test.go Show resolved Hide resolved
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

There is a logical error in TestBzzBzzHandshakeWithMessage condition check causing the test to fail.

bzzeth/bzzeth_test.go Outdated Show resolved Hide resolved
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

Thanks Zahoor! LGTM.

Copy link
Member

@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.

approved but #1756

if err != nil {
t.Fatal(err)
}
if _, ok := b.peers.peers[node.ID()]; ok {
t.Fatalf("peer still connected")
// after successful handshake, expect peer added to peer pool
Copy link
Member

Choose a reason for hiding this comment

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

wrong comment

Copy link
Member

Choose a reason for hiding this comment

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

there is a disconnected call on the tester.

t.Fatalf("peer is not connected")
// after successful handshake, expect peer added to peer pool
var p *Peer
for i := 0; i < 10; i++ {
Copy link
Member

Choose a reason for hiding this comment

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

dry up code


func isPeerDisconnected(id enode.ID, b *BzzEth) (p *Peer) {
Copy link
Member

Choose a reason for hiding this comment

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

imprecise, this is testing if peer is not in testpool

@zelig zelig merged commit 88dba2d into master Sep 14, 2019
@zelig zelig changed the title Idle when a swarm node is connected to bzzeth bzzeth: protocol runloop now quits on peer disconnect Sep 14, 2019
@skylenet skylenet added this to the 0.5.0 milestone Sep 17, 2019
@acud acud deleted the bug-1730 branch October 1, 2019 13:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

swarm node doesn't reconnect to peers correctly after restart
4 participants