public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Mike Hearn <mike@plan99.net>
To: Sergio Lerner <sergiolerner@certimix.com>
Cc: bitcoin-development <bitcoin-development@lists.sourceforge.net>
Subject: Re: [Bitcoin-development] Question on creating test cases for block.CheckBlock()
Date: Tue, 22 Jul 2014 13:13:50 +0200	[thread overview]
Message-ID: <CANEZrP3q6QdVH1P0_FyOkE6SzG338pAGJ6NzDCEj52bXwnW-Sg@mail.gmail.com> (raw)
In-Reply-To: <53CD4E3A.1000605@certimix.com>

[-- Attachment #1: Type: text/plain, Size: 2194 bytes --]

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
>

[-- Attachment #2: Type: text/html, Size: 2872 bytes --]

      reply	other threads:[~2014-07-22 11:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 17:30 [Bitcoin-development] Question on creating test cases for block.CheckBlock() Sergio Lerner
2014-07-22 11:13 ` Mike Hearn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANEZrP3q6QdVH1P0_FyOkE6SzG338pAGJ6NzDCEj52bXwnW-Sg@mail.gmail.com \
    --to=mike@plan99.net \
    --cc=bitcoin-development@lists.sourceforge.net \
    --cc=sergiolerner@certimix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox