Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Aug 27, 2021

Wait until the connection is fully established on both sides (verack). Fixes #22714

@fanquake fanquake added the Tests label Aug 27, 2021
# * Must have a verack message before anything else
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
Copy link
Member

@laanwj laanwj Aug 27, 2021

Choose a reason for hiding this comment

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

Any reason to use pop here instead of get? (I don't think so, there's no reason to mutate the structure)
Also: >= 24 might be more robust; it's clearly wrong if more than one verack gets sent, but it shouldn't hang forever in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the existing code, so I didn't touch it. I forgot to mention to review with --ignore-all-space.

I think it is fine for tests to fail when two veracks are sent.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the existing code, so I didn't touch it.

I was thinking that .get(key, default) did not exist in older Python versions but even Python 2.7 supports it. However, the change comes from this PR #18866 :-)

Still I think .pop('verack', 0) ->.get('verack', 0) should work just fine as proposed by @laanwj and it seems more natural.

@kiminuo
Copy link
Contributor

kiminuo commented Sep 24, 2021

utACK fa04f26

The change looks good me.

@maflcko maflcko merged commit 442e32e into bitcoin:master Sep 25, 2021
@maflcko maflcko deleted the 2108-testRaceConnect branch September 25, 2021 07:00
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 25, 2021
fa04f26 test: Avoid race after connect_nodes (MarcoFalke)

Pull request description:

  Wait until the connection is fully established on both sides (verack). Fixes bitcoin#22714

ACKs for top commit:
  kiminuo:
    utACK fa04f26

Tree-SHA512: bc2c44b44b688086ff84046924cf5251dd625584e93ce8fa17de27023855b32f3bb55109b846abbcec775e2836c7f3c5a81d6b4aff7c4ac065b9aefa044c1883
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: wait_until() failure in p2p_permissions.py
4 participants