test: Fix wait_for_debug_log UnicodeDecodeError #25294

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2206-test-emoji-decode-🎲 changing 2 files +26 −27
  1. maflcko commented at 2:53 PM on June 7, 2022: member

    Fix the intermittent UnicodeDecodeError when the debug log is truncated on an (multi-byte) unicode character by treating everything as bytes.

    Also, remove the ignore_case option and there.search+re.escape wrap. All of this is unused and doesn't exist on raw byte strings.

    Fixes https://github.com/bitcoin/bitcoin/issues/24575

  2. in test/functional/feature_init.py:77 in faf4c03b9c outdated
      93 |          if self.is_wallet_compiled():
      94 | -            lines_to_terminate_after.append('Verifying wallet')
      95 | +            lines_to_terminate_after.append(b'Verifying wallet')
      96 |  
      97 |          for terminate_line in lines_to_terminate_after:
      98 |              self.log.info(f"Starting node and will exit after line '{terminate_line}'")
    


    jonatack commented at 3:23 PM on June 7, 2022:

    nit, maybe clean up this log by converting the bytes back to a string, or by dropping the single quotes

    2022-06-07T16:30:25.742000Z TestFramework (INFO): Starting node and will exit after line 'b'Validating signatures for all blocks''
    2022-06-07T16:30:26.322000Z TestFramework (INFO): Starting node and will exit after line 'b'scheduler thread start''
    2022-06-07T16:30:26.663000Z TestFramework (INFO): Starting node and will exit after line 'b'Starting HTTP server''
    2022-06-07T16:30:27.137000Z TestFramework (INFO): Starting node and will exit after line 'b'Loading P2P addresses''
    2022-06-07T16:30:27.558000Z TestFramework (INFO): Starting node and will exit after line 'b'Loading banlist''
    2022-06-07T16:30:27.986000Z TestFramework (INFO): Starting node and will exit after line 'b'Loading block index''
    2022-06-07T16:30:28.460000Z TestFramework (INFO): Starting node and will exit after line 'b'Switching active chainstate
    ...
    

    maflcko commented at 6:55 PM on June 7, 2022:

    thx, fixed

  3. bitcoin deleted a comment on Jun 7, 2022
  4. jonatack commented at 4:37 PM on June 7, 2022: contributor

    ACK

  5. laanwj added the label Tests on Jun 7, 2022
  6. test: Fix wait_for_debug_log UnicodeDecodeError fa74b63c01
  7. maflcko force-pushed on Jun 7, 2022
  8. jonatack commented at 12:22 PM on June 8, 2022: contributor

    ACK fa74b63c01db412f6a4378cb669d89496a89d02e

  9. brunoerg approved
  10. brunoerg commented at 1:09 PM on June 8, 2022: contributor

    ACK fa74b63c01db412f6a4378cb669d89496a89d02e

  11. maflcko merged this on Jun 8, 2022
  12. maflcko closed this on Jun 8, 2022

  13. maflcko deleted the branch on Jun 8, 2022
  14. sidhujag referenced this in commit 50bcbc4a00 on Jun 13, 2022
  15. PiRK commented at 10:54 AM on November 25, 2022: contributor

    @MarcoFalke I think line 451 of test_node.py is now broken. log is now no longer a string, but bytes.

                if time.time() >= time_end:
                    print_log = " - " + "\n - ".join(log.splitlines())
                    break
    

    mypy detected this when I tried adding a typehint (List[bytes]) to the expected_msgs parameter of wait_for_debug_log.

    This could work

                if time.time() >= time_end:
                    print_log = " - " + "\n - ".join([f"\n - {line.decode()}" for line in log.splitlines()])
                    break
    
    
  16. Fabcien referenced this in commit 9f3d2d1810 on Nov 25, 2022
  17. bitcoin locked this on Nov 25, 2023

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-24 09:15 UTC

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