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.
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-
JBaczuk commented at 9:42 PM on June 27, 2018: contributor
-
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.
practicalswift commented at 9:48 PM on June 27, 2018: contributorThe action described in the commit comment is more narrow than the action performed in the commit. Please adjust the comment. Also, please squash.
fanquake added the label Tests on Jun 27, 2018JBaczuk force-pushed on Jun 27, 2018JBaczuk force-pushed on Jun 28, 2018in 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
JBaczuk force-pushed on Jun 28, 2018ken2812221 commented at 6:55 AM on July 12, 2018: contributorutACK 669dfa98bfbb3f70ce62fb1fbb2bad0a43fb0726
DrahtBot closed this on Aug 25, 2018DrahtBot 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.
DrahtBot reopened this on Aug 25, 2018in 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 :-)
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 :-)
MarcoFalke commented at 5:49 PM on May 20, 2019: memberPlease squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits
sipa commented at 6:26 PM on May 20, 2019: memberutACK code, please squash.
parameterize hard coded numbers referring to miner conf window 2c448d6bc7JBaczuk force-pushed on May 21, 2019JBaczuk commented at 2:37 AM on May 21, 2019: contributorsquished. 🙂
MarcoFalke merged this on May 21, 2019MarcoFalke closed this on May 21, 2019MarcoFalke referenced this in commit 3001cc61cf on May 21, 2019in 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.
PastaPastaPasta referenced this in commit 35df4207e2 on Jun 27, 2021PastaPastaPasta referenced this in commit 7a7f8ebae7 on Jun 28, 2021PastaPastaPasta referenced this in commit 62178a2cf6 on Jun 29, 2021PastaPastaPasta referenced this in commit cbcb6ad9e3 on Jul 1, 2021PastaPastaPasta referenced this in commit 5fac8da4f4 on Jul 1, 2021PastaPastaPasta referenced this in commit 29747bf8e3 on Jul 12, 2021MarcoFalke locked this on Dec 16, 2021Labels
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