test: replace assert with assert_equal and assert_greater_than #32091

pull Chand-ra wants to merge 1 commits into bitcoin:master from Chand-ra:assert changing 1 files +12 −12
  1. Chand-ra commented at 12:47 pm on March 18, 2025: none

    In test/functional/interface_usdt_net.py, assert_equal is already used to check for equality between objects. Replace assert.*== with assert_equal and assert.*> with assert_greater_than to further easify debugging.

    Relevant issue: #23119

  2. DrahtBot commented at 12:47 pm on March 18, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32091.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theStack, maflcko, 0xB10C, brunoerg, i-am-yuvi

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Mar 18, 2025
  4. maflcko commented at 12:51 pm on March 18, 2025: member
    lgtm ACK 93fdaf1ca00de0bc46eb2455732582c34cef58b5
  5. test: replace assert with assert_equal and assert_greater_than
    In test/functional/interface_usdt_net.py, assert_equal is already
    used to check for equality between objects. Replace 'assert.*=='
    with 'assert_equal' and 'assert.*>' with 'assert_greater_than'
    to further easify debugging.
    387385ba1e
  6. in test/functional/interface_usdt_net.py:484 in 93fdaf1ca0 outdated
    478@@ -479,9 +479,9 @@ def handle_misbehaving_connection(_, data, __):
    479 
    480         assert_equal(EXPECTED_MISBEHAVING_CONNECTIONS, len(misbehaving_connections))
    481         for misbehaving_connection in misbehaving_connections:
    482-            assert misbehaving_connection.id > 0
    483-            assert len(misbehaving_connection.message) > 0
    484-            assert misbehaving_connection.message == b"headers message size = 2001"
    485+            assert_greater_than(misbehaving_connection.id, 0)
    486+            assert_greater_than(len(misbehaving_connection.message), 0)
    487+            assert_equal(misbehaving_connection.message, b"headers message size= 2001")
    


    maflcko commented at 12:53 pm on March 18, 2025:
    actually, this looks wrong. Let’s hope the test/CI fails.


    Chand-ra commented at 1:48 pm on March 18, 2025:
    I ran the entire test suite from my build directory using ctest --output-on-failure and the modified test passed just fine there. Any idea on what might cause the discrepancy?

    theStack commented at 3:47 pm on March 18, 2025:

    I ran the entire test suite from my build directory using ctest --output-on-failure and the modified test passed just fine there. Any idea on what might cause the discrepancy?

    I assume you built bitcoind without USDT support. One simple way to do enable it is e.g. configuring CMake via cmake --preset dev-mode. What happens if you run the individual test, i.e. $ ./build/test/functional/interface_usdt_net.py?


    Chand-ra commented at 6:12 pm on March 18, 2025:

    What happens if you run the individual test, i.e. $ ./build/test/functional/interface_usdt_net.py

    You were right, I didn’t compile bitcoind with USDT support. Running the individual test results in the following output:

    02025-03-18T18:06:36.018000Z TestFramework (INFO): PRNG seed is: 6897053979890084060
    12025-03-18T18:06:36.021000Z TestFramework (WARNING): Test Skipped: bitcoind has not been built with USDT tracepoints enabled.
    22025-03-18T18:06:36.074000Z TestFramework (INFO): Stopping nodes
    32025-03-18T18:06:36.075000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_m5zcf3_7 on exit
    42025-03-18T18:06:36.075000Z TestFramework (INFO): Test skipped
    

    Running the test in dev-mode build configuration with cmake --preset dev-mode seems to fix this.

  7. Chand-ra force-pushed on Mar 18, 2025
  8. theStack approved
  9. theStack commented at 3:41 pm on March 18, 2025: contributor
    utACK 387385ba1edf9febdc75d39bd77b35b29714b3d0
  10. DrahtBot requested review from maflcko on Mar 18, 2025
  11. maflcko commented at 3:48 pm on March 18, 2025: member
    lgtm ACK 387385ba1edf9febdc75d39bd77b35b29714b3d0
  12. 0xB10C commented at 6:40 am on March 19, 2025: contributor
    had a quick look, lgtm ACK 387385ba1edf9febdc75d39bd77b35b29714b3d0
  13. brunoerg approved
  14. brunoerg commented at 12:55 pm on March 19, 2025: contributor
    code review ACK 387385ba1edf9febdc75d39bd77b35b29714b3d0
  15. i-am-yuvi commented at 5:01 pm on March 19, 2025: contributor
    Great! ACK 387385ba1edf9febdc75d39bd77b35b29714b3d0
  16. fanquake merged this on Mar 20, 2025
  17. fanquake closed this on Mar 20, 2025


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: 2025-03-28 15:12 UTC

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