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

pytest: make run_handshake handle unsolicited Block messages #4437

Merged
merged 3 commits into from
Jul 1, 2021

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Jun 29, 2021

This addresses the following failure:

Traceback (most recent call last):
  File "tests/spec/network/peers_request.py", line 44, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "tests/spec/network/peers_request.py", line 35, in main
    await run_handshake(conn1, nodes[0].node_key.pk, key_pair_1, listen_port=12346)
  File "lib/peer.py", line 182, in run_handshake
    assert response.enum == 'Handshake', response.enum if response.enum != 'HandshakeFailure' else response.HandshakeFailure[1].enum
AssertionError: Block

Fixes: #4432

This addresses the following failure:

    Traceback (most recent call last):
      File "tests/spec/network/peers_request.py", line 44, in <module>
        asyncio.run(main())
      File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
        return loop.run_until_complete(main)
      File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
        return future.result()
      File "tests/spec/network/peers_request.py", line 35, in main
        await run_handshake(conn1, nodes[0].node_key.pk, key_pair_1, listen_port=12346)
      File "lib/peer.py", line 182, in run_handshake
        assert response.enum == 'Handshake', response.enum if response.enum != 'HandshakeFailure' else response.HandshakeFailure[1].enum
    AssertionError: Block

Fixes: near#4432
Copy link
Collaborator

@bowenwang1996 bowenwang1996 left a comment

Choose a reason for hiding this comment

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

This is weird. Handshake is the first message we exchange when establishing a connection. Therefore this implies that the test may not intercept the messages correctly. cc @mfornet @pmnoxx

@mina86
Copy link
Contributor Author

mina86 commented Jun 30, 2021

I think what happened was that between flagging handshake as finished and sending handshake to the pear, another thread notice the new peer and sent the block. The flow of the handshake is that it first goes to Peer which then sends Consolidate to PeerManager which registers a new peer and responds back to Peer with an accept and only then Peer sends handshake back to the other node.

pytest/lib/peer.py Outdated Show resolved Hide resolved
@near-bulldozer near-bulldozer bot merged commit 60713c9 into near:master Jul 1, 2021
@mina86 mina86 deleted the t0 branch July 1, 2021 20:06
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.

Nayduck regression
3 participants