test: add BIP157 message parsing support (via MESSAGEMAP) #25126

pull theStack wants to merge 2 commits into bitcoin:master from theStack:202205-test-support_BIP157_deser_via_messagemap changing 2 files +9 −3
  1. theStack commented at 12:14 PM on May 13, 2022: member

    The script message-capture-parser.py currently doesn't support parsing the BIP157 messages getcfilters, getcfheaders and getcfcheckpt, e.g.

    $ ./contrib/message-capture/message-capture-parser.py msgs_recv.dat
    ...
        WARNING - Unrecognized message type b'getcfcheckpt' in /home/thestack/bitcoin/msgs_recv.dat
    ...
    

    This PR fixes this by adding the missing message type mappings to the MESSAGEMAP in the test framework and add default-constructors for the corresponding msg_... classes.

    Without the second commit, the following error message would occur:

      File "/home/thestack/bitcoin/./contrib/message-capture/message-capture-parser.py", line 141, in process_file
        msg = MESSAGEMAP[msgtype]()
    TypeError: __init__() missing 2 required positional arguments: 'filter_type' and 'stop_hash'
    
  2. test: p2p: add missing BIP157 message types to MESSAGEMAP 71e4cfefe7
  3. test: make BIP157 messages default-constructible (MESSAGEMAP compatibility)
    In order to deserialize received or read messages via lookup in
    MESSAGEMAP (e.g.: `t = MESSAGEMAP[msgtype]()`), the messages must have a
    default constructor, i.e. there needs to be the possibility to
    initialize them with zero arguments.
    5dc6d92077
  4. theStack commented at 12:16 PM on May 13, 2022: member

    Can be reproduced with the following input file:

    $ xxd -p msgs_recv.dat
    544fe2d1e1de050076657273696f6e00000000006f000000801101000900
    000000000000812d7e620000000001000000000000000000000000000000
    0000ffff7f000001301b010000000000000000000000000000000000ffff
    000000000000e49e8d5430100b09192f707974686f6e2d7032702d746573
    7465723a302e302e332fffffffff01d49ee2d1e1de050077747869647265
    6c61790000000000001ca1e2d1e1de050076657261636b00000000000000
    0000009fb7e2d1e1de050067657461646472000000000000000000c8bfe2
    d1e1de0500706f6e670000000000000000080000006d37706c0c0fcf9a5a
    11e3d1e1de050070696e6700000000000000000800000001000000000000
    006f1ae4d1e1de05006765746366636865636b7074210000000006226e46
    111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f1120
    e4d1e1de050070696e670000000000000000080000000200000000000000
    

    (Save the hex-lines into a file and convert it into the dump via $ xxd -p -r hexdump.txt > msgs_recv.dat).

  5. DrahtBot added the label Tests on May 13, 2022
  6. dunxen approved
  7. dunxen commented at 5:01 PM on May 18, 2022: contributor

    tACK 5dc6d92

    Reproduced error on master. Checked that adding default values to the constructor was required.

  8. MarcoFalke merged this on May 18, 2022
  9. MarcoFalke closed this on May 18, 2022

  10. theStack deleted the branch on May 18, 2022
  11. sidhujag referenced this in commit a9b6732835 on May 28, 2022
  12. DrahtBot locked this on May 18, 2023
Contributors
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-14 21:13 UTC

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