Question on creating test cases for block.CheckBlock()



Summary:

Currently, there is no infrastructure for writing blockchain unit tests. However, the pull tester has been extended as a solution to this problem. The pull tester is a bitcoinj based app called BitcoindComparisonTool that builds a regtest chain and submits it to a local regtest node. It tests reorgs and various rules by speaking to the node only via P2P. However, verifying your BIP depends on how easy it is to do so via P2P. Additionally, the code needs cleaning up, as there is a lot of copy/paste coding going on in there.In an email thread from July 21, 2014, Sergio Lerner discusses two ways of testing a BIP that involves modifying the block acceptance rules. The two ways are mining blocks on the testnet and creating test cases for Bitcoin Core. Lerner wants to create test cases for block.CheckBlock(), which involves verifying 100 dynamically generated blocks. However, he is unsure about the state of the blockchain when a test case is executed and what blocks are in the blockchain. The checkblock_tests.cpp seems to be the only test case for CheckBlock() and assumes the mainnet is configured. Lerner needs to use the regtest to create blocks of difficulty 1.


Updated on: 2023-06-09T01:27:48.677743+00:00