From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1X9Y18-0000Lb-3p for bitcoin-development@lists.sourceforge.net; Tue, 22 Jul 2014 11:13:58 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.219.45 as permitted sender) client-ip=209.85.219.45; envelope-from=mh.in.england@gmail.com; helo=mail-oa0-f45.google.com; Received: from mail-oa0-f45.google.com ([209.85.219.45]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1X9Y16-0007aA-Dt for bitcoin-development@lists.sourceforge.net; Tue, 22 Jul 2014 11:13:58 +0000 Received: by mail-oa0-f45.google.com with SMTP id i7so9399493oag.4 for ; Tue, 22 Jul 2014 04:13:51 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.70.205 with SMTP id o13mr46997343oeu.38.1406027630888; Tue, 22 Jul 2014 04:13:50 -0700 (PDT) Sender: mh.in.england@gmail.com Received: by 10.76.35.234 with HTTP; Tue, 22 Jul 2014 04:13:50 -0700 (PDT) In-Reply-To: <53CD4E3A.1000605@certimix.com> References: <53CD4E3A.1000605@certimix.com> Date: Tue, 22 Jul 2014 13:13:50 +0200 X-Google-Sender-Auth: WMcWBRzAHgs-Gm3oZvS-dwtx-AM Message-ID: From: Mike Hearn To: Sergio Lerner Content-Type: multipart/alternative; boundary=001a11333df67bcdc504fec65122 X-Spam-Score: -0.5 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (mh.in.england[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.0 HTML_MESSAGE BODY: HTML included in message 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1X9Y16-0007aA-Dt Cc: bitcoin-development Subject: Re: [Bitcoin-development] Question on creating test cases for block.CheckBlock() X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jul 2014 11:13:58 -0000 --001a11333df67bcdc504fec65122 Content-Type: text/plain; charset=UTF-8 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 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 > --001a11333df67bcdc504fec65122 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
There is no infrastructure for writing block chain unit te= sts unfortunately. Last time I tried to fix this I ended up going down a ra= bbit hole - Bitcoin wasn't written to be a testable codebase and as a r= esult reinitialising it from scratch is rather difficult (there are lots of= global variables that have to be reset to particular states and no real li= st 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 th= ings like reorgs and various rules. It speaks to the node only via P2P so h= ow easy it is to verify your BIP works will depend on that. Also the code n= eeds 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 modi= fy 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/b= ds
_______________________________________________
Bitcoin-development mailing list
Bitcoin-develo= pment@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-de= velopment

--001a11333df67bcdc504fec65122--