test: deploymentinfo.cpp unit tests #25219

pull natanleung wants to merge 1 commits into bitcoin:master from natanleung:deploymentinfo_unit_test changing 2 files +30 −0
  1. natanleung commented at 10:33 PM on May 25, 2022: none

    This patch implements the unit tests for deploymentinfo.h and deploymentinfo.cpp. These changes will improve test coverage and run within the unit test suite.

    Test coverage: https://marcofalke.github.io/btc_cov/test_bitcoin.coverage/src/deploymentinfo.h.gcov.html https://marcofalke.github.io/btc_cov/test_bitcoin.coverage/src/deploymentinfo.cpp.gcov.html

    Test execution excerpt:

    test/deploymentinfo_tests.cpp(10): Entering test suite "deploymentinfo_tests"
    test/deploymentinfo_tests.cpp(12): Entering test case "name_from_pos"
    test/deploymentinfo_tests.cpp(15): info: check DeploymentName(Consensus::DEPLOYMENT_TESTDUMMY) == VersionBitsDeploymentInfo[Consensus::DEPLOYMENT_TESTDUMMY].name has passed
    test/deploymentinfo_tests.cpp(16): info: check DeploymentName(Consensus::DEPLOYMENT_TAPROOT) == VersionBitsDeploymentInfo[Consensus::DEPLOYMENT_TAPROOT].name has passed
    test/deploymentinfo_tests.cpp(12): Leaving test case "name_from_pos"; testing time: 7564us
    test/deploymentinfo_tests.cpp(19): Entering test case "name_from_dep"
    test/deploymentinfo_tests.cpp(22): info: check DeploymentName(Consensus::DEPLOYMENT_HEIGHTINCB) == "bip34" has passed
    test/deploymentinfo_tests.cpp(23): info: check DeploymentName(Consensus::DEPLOYMENT_CLTV) == "bip65" has passed
    test/deploymentinfo_tests.cpp(24): info: check DeploymentName(Consensus::DEPLOYMENT_DERSIG) == "bip66" has passed
    test/deploymentinfo_tests.cpp(25): info: check DeploymentName(Consensus::DEPLOYMENT_CSV) == "csv" has passed
    test/deploymentinfo_tests.cpp(26): info: check DeploymentName(Consensus::DEPLOYMENT_SEGWIT) == "segwit" has passed
    test/deploymentinfo_tests.cpp(19): Leaving test case "name_from_dep"; testing time: 2011us
    test/deploymentinfo_tests.cpp(10): Leaving test suite "deploymentinfo_tests"; testing time: 9707us
    
  2. test: deploymentinfo.cpp unit tests 4c1a3d195b
  3. DrahtBot added the label Build system on May 25, 2022
  4. MarcoFalke commented at 10:22 AM on May 27, 2022: member

    Not sure if this is worth it. We already have a test to check the name in the functional tests, see https://marcofalke.github.io/btc_cov/total.coverage/src/deploymentinfo.cpp.gcov.html

    Test coverage is nice, but shouldn't be a goal in itself. The goal should be to avoid bugs reaching end users.

  5. laanwj commented at 1:41 PM on June 3, 2022: member

    Thanks for your first contribution!

    Not sure if this is worth

    At least these are very small and quick to run tests!

    But I have to agree that I'm not sure it adds useful testing. Checking the content of a static mapping against its expected values creates an extra place where changes need to be made, but I'm not sure it'd find bugs.

  6. MarcoFalke commented at 1:58 PM on June 3, 2022: member

    Thank you for your contribution, but I am closing for now. It seems unlikely that someone changes the consensus deployments but everyone forgets to check the name returned via RPC. Not to mention the functional test that already checks the same thing. It seems more likely that this will add maintenance burden in the future.

  7. MarcoFalke closed this on Jun 3, 2022

  8. natanleung deleted the branch on Jun 3, 2022
  9. DrahtBot locked this on Jun 3, 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-13 15:13 UTC

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