Bitcoin Forum
August 14, 2024, 06:22:21 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Blockchain Test Data  (Read 716 times)
pmlyon (OP)
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile
June 18, 2013, 11:54:41 AM
 #1

Does there exist a set of blocks that can be used for unit testing? I'm thinking something like a few thousand blocks that is representative of everything a node would need to implement.

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1257


May Bitcoin be touched by his Noodly Appendage


View Profile
June 18, 2013, 12:04:37 PM
 #2

All blocks have the same, fixed structure so using the genesis block and the last block should be enough
It's reading transaction that can be trickier

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
pmlyon (OP)
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile
June 18, 2013, 12:16:20 PM
 #3

Using the real blockchain would be too slow and large for unit testing purposes, I think.

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
jackjack
Legendary
*
Offline Offline

Activity: 1176
Merit: 1257


May Bitcoin be touched by his Noodly Appendage


View Profile
June 18, 2013, 01:53:04 PM
 #4

I was suggesting using only two blocks, the first and the last one.
I'm not sure I really understand your question though: are you looking for data to test a blockchain parser?

Own address: 19QkqAza7BHFTuoz9N8UQkryP4E9jHo4N3 - Pywallet support: 1AQDfx22pKGgXnUZFL1e4UKos3QqvRzNh5 - Bitcointalk++ script support: 1Pxeccscj1ygseTdSV1qUqQCanp2B2NMM2
Pywallet: instructions. Encrypted wallet support, export/import keys/addresses, backup wallets, export/import CSV data from/into wallet, merge wallets, delete/import addresses and transactions, recover altcoins sent to bitcoin addresses, sign/verify messages and files with Bitcoin addresses, recover deleted wallets, etc.
pmlyon (OP)
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile
June 18, 2013, 02:00:02 PM
 #5

Ahh, that makes more sense. Smiley What I'm thinking is a bunch of blocks, some valid, some not. You'd have transactions, some valid, some not. Things like orphan blocks would be present. I'm still really new to this, so I can't really give a full list of what all would comprise a representative sample.

You could feed this data into a parser, yes. You could also feed it into a system that validates blocks, another that deals with constructing the blockchain and handling orphans, etc. You could make a mini unit test network consisting of a couple of nodes broadcasting the test data blocks, and use that to validate node functionality.

The expected results could even be described in some kind of format so that different implementations written in different languages could leverage this same set of test data, creating a validation suite of sorts.

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1007


View Profile
June 18, 2013, 02:09:17 PM
 #6

Ideally this data would be starting with the Bitcoin genesis block and be structured in a way that blocks can be added from the outside too (e.g. a new block is announced on the network but it builds on a block 10 blocks behind, then the next 10 blocks also build on this fork and your client needs to be able to reorg).

Also some blocks with strange transactions, invalid headers (that have difficulty just off by one - as you start with diff=1 it shouldn't be too hard to find this), difficulty rising/falling more than 4-fold after a retarget...

I guess it would be interesting to have such a data set.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
pmlyon (OP)
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile
June 18, 2013, 02:18:00 PM
 #7

I think you'd want a one-click repeatable way to generate the test data as well. Some kind of program that would interact with bitcoind, for example, to generate the transactions and blocks. I'm not sure how much invalid data you could introduce directly using bitcoind, but you could also twiddle the bits after the fact to introduce errors.

This still gives the raw blocks, so other implementations don't need to depend on bitcoind at all for the test suite. But it means you could roll out updates to the test suite much more easily.

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
etotheipi
Legendary
*
expert
Offline Offline

Activity: 1428
Merit: 1093


Core Armory Developer


View Profile WWW
June 18, 2013, 03:52:31 PM
 #8

I think you'd want a one-click repeatable way to generate the test data as well. Some kind of program that would interact with bitcoind, for example, to generate the transactions and blocks. I'm not sure how much invalid data you could introduce directly using bitcoind, but you could also twiddle the bits after the fact to introduce errors.

This still gives the raw blocks, so other implementations don't need to depend on bitcoind at all for the test suite. But it means you could roll out updates to the test suite much more easily.

A long time ago I created a re-org unit test:

https://bitcointalk.org/index.php?topic=46370.msg577556#msg577556

I created a completely valid blockchain, with valid signatures and proof of work, an orphan chain and a double-spend.  It's valid as long as you set your COINBASE_MATURITY to 1 (so coinbase blocks are immediately spendable).  This has been wildly invaluable for me to test all kinds of different logic.  The only thing I regret doing was not adding a couple more blocks to re-org back onto the original chain.  That would've been even more stressful...



Founder and CEO of Armory Technologies, Inc.
Armory Bitcoin Wallet: Bringing cold storage to the average user!
Only use Armory software signed by the Armory Offline Signing Key (0x98832223)

Please donate to the Armory project by clicking here!    (or donate directly via 1QBDLYTDFHHZAABYSKGKPWKLSXZWCCJQBX -- yes, it's a real address!)
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1356


aka tonikt


View Profile WWW
June 18, 2013, 03:58:32 PM
 #9

Does there exist a set of blocks that can be used for unit testing? I'm thinking something like a few thousand blocks that is representative of everything a node would need to implement.
testnet3 chain is very good for this.
it does not have everything, but I believe it has enough to keep you busy for awhile... Smiley

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!