Tests: parameterize adjustment period in versionbits_computeblockversion #13555

pull JBaczuk wants to merge 1 commits into bitcoin:master from JBaczuk:parameterize_adj_period_in_versionbits_computeblockversion_unit_test changing 1 files +15 −15
  1. JBaczuk commented at 9:42 PM on June 27, 2018: contributor

    Replace hard coded values (eg. 2016) with mainnetParams.nMinerConfirmationWindow where appropriate. This parameterizes hard coded values in the unit test that refer to the Miner Confirmation Window, which currently is 2016. This includes values not exactly 2016 but which were derived from it. Also changed int to uint32_t where appropriate to avoid compiler warnings. This makes one source of truth, and also helps people who might be adjusting this value in testing so the unit tests don't break.

  2. in .vscode/settings.json:1 in 483b68889d outdated
       0 | @@ -0,0 +1,5 @@
       1 | +{
    


    practicalswift commented at 9:47 PM on June 27, 2018:

    Please remove this file.

  3. practicalswift commented at 9:48 PM on June 27, 2018: contributor

    The action described in the commit comment is more narrow than the action performed in the commit. Please adjust the comment. Also, please squash.

  4. fanquake added the label Tests on Jun 27, 2018
  5. JBaczuk force-pushed on Jun 27, 2018
  6. JBaczuk force-pushed on Jun 28, 2018
  7. in src/test/versionbits_tests.cpp:278 in d89e15c848 outdated
     277 |  
     278 | -    // Mine 2011 more blocks at the old time, and check that CBV isn't setting the bit yet.
     279 | -    for (int i=1; i<2012; i++) {
     280 | -        lastBlock = firstChain.Mine(2016+i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
     281 | +    // Mine more blocks (4 less than the adjustment period) at the old time, and check that CBV isn't setting the bit yet.
     282 | +    for (uint32_t i=1; i<mainnetParams.nMinerConfirmationWindow-4; i++) {
    


    practicalswift commented at 4:52 AM on June 28, 2018:

    Nit: for (uint32_t i = 1; i < mainnetParams.nMinerConfirmationWindow - 4; i++) { + corresponding whitespace change throughout this PR


    JBaczuk commented at 2:58 PM on June 28, 2018:

    Done

  8. JBaczuk force-pushed on Jun 28, 2018
  9. ken2812221 commented at 6:55 AM on July 12, 2018: contributor

    utACK 669dfa98bfbb3f70ce62fb1fbb2bad0a43fb0726

  10. DrahtBot closed this on Aug 25, 2018

  11. DrahtBot commented at 8:55 PM on August 25, 2018: member

    <!--5d09a71f8925f3f132321140b44b946d-->The last travis run for this pull request was 58 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened.

  12. DrahtBot reopened this on Aug 25, 2018

  13. in src/test/versionbits_tests.cpp:301 in 669dfa98bf outdated
     305 |  
     306 |      // Check that ComputeBlockVersion will set the bit until nTimeout
     307 |      nTime += 600;
     308 | -    int blocksToMine = 4032; // test blocks for up to 2 time periods
     309 | -    int nHeight = 6048;
     310 | +    int blocksToMine = mainnetParams.nMinerConfirmationWindow * 2; // test blocks for up to 2 time periods
    


    practicalswift commented at 9:33 AM on October 4, 2018:

    Make this sign conversion explicit or get rid of the conversion :-)

  14. in src/test/versionbits_tests.cpp:302 in 669dfa98bf outdated
     306 |      // Check that ComputeBlockVersion will set the bit until nTimeout
     307 |      nTime += 600;
     308 | -    int blocksToMine = 4032; // test blocks for up to 2 time periods
     309 | -    int nHeight = 6048;
     310 | +    int blocksToMine = mainnetParams.nMinerConfirmationWindow * 2; // test blocks for up to 2 time periods
     311 | +    int nHeight = mainnetParams.nMinerConfirmationWindow * 3;
    


    practicalswift commented at 9:33 AM on October 4, 2018:

    Same here :-)

  15. MarcoFalke commented at 5:49 PM on May 20, 2019: member
  16. sipa commented at 6:26 PM on May 20, 2019: member

    utACK code, please squash.

  17. parameterize hard coded numbers referring to miner conf window 2c448d6bc7
  18. JBaczuk force-pushed on May 21, 2019
  19. JBaczuk commented at 2:37 AM on May 21, 2019: contributor

    squished. 🙂

  20. MarcoFalke merged this on May 21, 2019
  21. MarcoFalke closed this on May 21, 2019

  22. MarcoFalke referenced this in commit 3001cc61cf on May 21, 2019
  23. in src/test/versionbits_tests.cpp:277 in 2c448d6bc7
     276 |      BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit), 0);
     277 |  
     278 | -    // Mine 2011 more blocks at the old time, and check that CBV isn't setting the bit yet.
     279 | -    for (int i=1; i<2012; i++) {
     280 | -        lastBlock = firstChain.Mine(2016+i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
     281 | +    // Mine more blocks (4 less than the adjustment period) at the old time, and check that CBV isn't setting the bit yet.
    


    jnewbery commented at 1:08 PM on May 21, 2019:

    it looks like this should be "5 less than the adjustment period"


    JBaczuk commented at 3:24 PM on May 21, 2019:

    yeah i'll fix that.

  24. PastaPastaPasta referenced this in commit 35df4207e2 on Jun 27, 2021
  25. PastaPastaPasta referenced this in commit 7a7f8ebae7 on Jun 28, 2021
  26. PastaPastaPasta referenced this in commit 62178a2cf6 on Jun 29, 2021
  27. PastaPastaPasta referenced this in commit cbcb6ad9e3 on Jul 1, 2021
  28. PastaPastaPasta referenced this in commit 5fac8da4f4 on Jul 1, 2021
  29. PastaPastaPasta referenced this in commit 29747bf8e3 on Jul 12, 2021
  30. MarcoFalke locked this on Dec 16, 2021

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

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