There is no infrastructure for writing block chain unit tests unfortunately. Last time I tried to fix this I ended up going down a rabbit hole - Bitcoin wasn't written to be a testable codebase and as a result reinitialising it from scratch is rather difficult (there are lots of global variables that have to be reset to particular states and no real list of where they are).

Instead what I ended up doing is extending the pull tester. This is a bitcoinj based app (BitcoindComparisonTool in the codebase) which builds a regtest chain and submits it to a local regtest node. It tests things like reorgs and various rules. It speaks to the node only via P2P so how easy it is to verify your BIP works will depend on that. Also the code needs cleaning up, there's a lot of copy/paste coding going on in there.




On Mon, Jul 21, 2014 at 7:30 PM, Sergio Lerner <sergiolerner@certimix.com> wrote:
I'm working on a BIP which needs to modify the block acceptance rules. I
have two ways of testing:

- Mining blocks on the testnet
- Creating test cases for Bitcoin Core.

I want to create those test cases for block.CheckBlock(), which involves
verifying 100 dynamically generated blocks.
What is the state of the blockchain when a test case is executed ? Is is
configured for the regtest, testnet3 or mainnet? What blocks are in the
blockchain? Only the genesis block?

checkblock_tests.cpp seems to be the only test case for CheckBlock() and
it assumes the mainnet is configured.
I need to use the regtest so I can create blocks of difficulty 1.

Best regards and thank you in advance,


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-development