test: Fix p2p_invalid_messages failing in Python 3.8 because of warning #17931

pull elichai wants to merge 1 commits into bitcoin:master from elichai:2020-01-coroutine changing 1 files +2 −2
  1. elichai commented at 1:04 PM on January 15, 2020: contributor

    In Python 3.8 p2p_invalid_messages.py fails because of the following warning python produce:

    2020-01-15T13:02:14.486000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_3xq0f6uh
    ./test/functional/p2p_invalid_messages.py:154: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
      asyncio.run_coroutine_threadsafe(asyncio.coroutine(swap_magic_bytes)(), NetworkThread.network_event_loop).result()
    2020-01-15T13:02:15.306000Z TestFramework (INFO): Sending a bunch of large, junk messages to test memory exhaustion. May take a bit...
    2020-01-15T13:02:17.971000Z TestFramework (INFO): Waiting for node to drop junk messages.
    2020-01-15T13:02:18.042000Z TestFramework.mininode (WARNING): Connection lost to 127.0.0.1:12826 due to [Errno 104] Connection reset by peer
    2020-01-15T13:02:18.141000Z TestFramework (INFO): Sending a message with incorrect size of 2
    2020-01-15T13:02:18.293000Z TestFramework (INFO): Sending a message with incorrect size of 77
    2020-01-15T13:02:18.344000Z TestFramework.mininode (WARNING): Connection lost to 127.0.0.1:12826 due to [Errno 104] Connection reset by peer
    2020-01-15T13:02:18.445000Z TestFramework (INFO): Sending a message with incorrect size of 78
    2020-01-15T13:02:18.597000Z TestFramework (INFO): Sending a message with incorrect size of 79
    2020-01-15T13:02:18.902000Z TestFramework (INFO): Stopping nodes
    2020-01-15T13:02:19.154000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_3xq0f6uh on exit
    2020-01-15T13:02:19.154000Z TestFramework (INFO): Tests successful
    

    so as it says I replaced the co-routine with async def which IIUC is supported since Python 3.5, so this makes the test pass both on 3.5+ and on 3.8 https://docs.python.org/3.5/library/asyncio-task.html ("The async def type of coroutine was added in Python 3.5, and is recommended if there is no need to support older Python versions")

  2. Replace coroutine with async def in p2p_invalid_messages.py f117fb00da
  3. fanquake added the label Tests on Jan 15, 2020
  4. laanwj commented at 1:38 PM on January 15, 2020: member

    I think it's somewhat strange for the test to fail on a warning, but I also think this change makes sense.

    ACK f117fb00da747147cddfb071c1427a2754c278cd if it passes travis

  5. elichai commented at 1:40 PM on January 15, 2020: contributor

    I think currently the tests fail if the python side prints anything to stdout/stderr

  6. fanquake approved
  7. fanquake commented at 9:44 AM on January 16, 2020: member

    ACK f117fb00da747147cddfb071c1427a2754c278cd - observed the failure (it's the only test that fails) with Python 3.8.1, tested the fix with 3.5.6 and 3.8.1. This is our only usage of asyncio.coroutine.

    72/136 - p2p_invalid_messages.py failed, Duration: 9 s
    
    stdout:
    2020-01-16T09:37:44.223000Z TestFramework (INFO): Initializing test directory /var/folders/z2/cn877pxd3czdfh47mfkmbwgm0000gn/T/test_runner_₿_🏃_20200116_173347/p2p_invalid_messages_62
    2020-01-16T09:37:46.045000Z TestFramework (INFO): Sending a bunch of large, junk messages to test memory exhaustion. May take a bit...
    2020-01-16T09:37:51.293000Z TestFramework (INFO): Waiting for node to drop junk messages.
    2020-01-16T09:37:51.344000Z TestFramework (INFO): Skipping test p2p_invalid_messages/1 (oversized message) under macOS
    2020-01-16T09:37:51.348000Z TestFramework (INFO): Sending a message with incorrect size of 2
    2020-01-16T09:37:51.413000Z TestFramework.mininode (WARNING): Connection lost to 127.0.0.1:11744 due to [Errno 54] Connection reset by peer
    2020-01-16T09:37:51.525000Z TestFramework (INFO): Sending a message with incorrect size of 77
    2020-01-16T09:37:51.585000Z TestFramework.mininode (WARNING): Connection lost to 127.0.0.1:11744 due to [Errno 54] Connection reset by peer
    2020-01-16T09:37:51.692000Z TestFramework (INFO): Sending a message with incorrect size of 78
    2020-01-16T09:37:51.880000Z TestFramework (INFO): Sending a message with incorrect size of 79
    2020-01-16T09:37:52.212000Z TestFramework (INFO): Stopping nodes
    2020-01-16T09:37:52.691000Z TestFramework (INFO): Cleaning up /var/folders/z2/cn877pxd3czdfh47mfkmbwgm0000gn/T/test_runner_₿_🏃_20200116_173347/p2p_invalid_messages_62 on exit
    2020-01-16T09:37:52.691000Z TestFramework (INFO): Tests successful
    
    
    stderr:
    /Users/michael/github/bitcoin/test/functional/p2p_invalid_messages.py:154: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
      asyncio.run_coroutine_threadsafe(asyncio.coroutine(swap_magic_bytes)(), NetworkThread.network_event_loop).result()
    
  8. fanquake referenced this in commit 4e8b564df0 on Jan 16, 2020
  9. fanquake merged this on Jan 16, 2020
  10. fanquake closed this on Jan 16, 2020

  11. elichai deleted the branch on Jan 16, 2020
  12. MarkLTZ referenced this in commit 8823f65197 on Apr 7, 2020
  13. MarkLTZ referenced this in commit 0a1571d657 on Apr 7, 2020
  14. deadalnix referenced this in commit 601266a81f on Jun 8, 2020
  15. ftrader referenced this in commit dd9c3380fb on Apr 14, 2021
  16. random-zebra referenced this in commit bffe509aed on Jun 28, 2021
  17. kittywhiskers referenced this in commit 47873f84e4 on Nov 2, 2021
  18. kittywhiskers referenced this in commit b0ee2a40a4 on Nov 3, 2021
  19. pravblockc referenced this in commit f618c44ecb on Nov 18, 2021
  20. DrahtBot locked this on Feb 15, 2022
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 09:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me