Author

Topic: Help wanted: more Script unit tests! (Read 1075 times)

hero member
Activity: 731
Merit: 503
Libertas a calumnia
May 01, 2012, 10:00:41 AM
#2
Very nice initiative Gavin.

Testnet transaction a17b21f52859ed326d1395d8a56d5c7389f5fc83c17b9140a71d7cb86fdf0f5f seems to use a lot of corner case, I'm still unable to validate it and I've already catched various errors in the implementation I'm working on.

ScriptSig is:
Code:
0
3046022100d73f633f114e0e0b324d87d38d34f22966a03b072803afa99c9408201f6d6dc6022100900e85be52ad2278d24e7edbb7269367f5f2d6f1bd338d017ca460008776614401
3044022071fef8ac0aa6318817dbd242bf51fb5b75be312aa31ecb44a0afe7b49fcf840302204c223179a383bb6fcb80312ac66e473345065f7d9136f9662d867acf96c12a4201
2
048c006ff0d2cfde86455086af5a25b88c2b81858aab67f6a3132c885a2cb9ec38e700576fd46c7d72d7d22555eee3a14e2876c643cd70b1b0a77fbf46e62331ac
04b68ef7d8f24d45e1771101e269c0aacf8d3ed7ebe12b65521712bba768ef53e1e84fff3afbee360acea0d1f461c013557f71d426ac17a293c5eebf06e468253e
0

ScriptPubKey is:
Code:
3 OP_ROLL OP_DUP 2 OP_GREATERTHANOREQUAL OP_VERIFY
3 OP_ROLL OP_SIZE OP_NOT OP_OVER OP_HASH160
80677c5392220db736455533477d0bc2fba65502
OP_EQUAL OP_BOOLOR OP_VERIFY 3 OP_ROLL OP_SIZE OP_NOT OP_OVER OP_HASH160
02d7aa2e76d9066fb2b3c41ff8839a5c81bdca19
OP_EQUAL OP_BOOLOR OP_VERIFY 3 OP_ROLL OP_SIZE OP_NOT OP_OVER OP_HASH160
10039ce4fdb5d4ee56148fe3935b9bfbbe4ecc89
OP_EQUAL OP_BOOLOR OP_VERIFY 3 OP_CHECKMULTISIG
legendary
Activity: 1652
Merit: 2301
Chief Scientist
April 20, 2012, 10:10:48 AM
#1
Cross-posted from the Alternative Clients sub-forum, since it looks like the alternative client folks are more interested in adding new features than figuring out exactly how the features we already have work:

Better testing, both for the Satoshi code and across different implementations, is right at the top of my priority list. So I wrote some code to make it easier to exercise edge cases in Script evaluation:
  https://github.com/bitcoin/bitcoin/pull/1121/files

The unit tests are data-driven by two files:
 script_valid.json  contains pairs of (scriptSig,scriptPubKey) that, when used in a transaction, should evaluate to true.
 script_invalid.json  contains pairs that are invalid for some reason.

I'm looking for help to expand those to cover all the quirky edge cases that might trip up alternative "fully validating" implementations (excluding OP_CHECKSIG/OP_CHECKMULTISIG, I'm still thinking about how best to write test cases for those). If you can help, please jump in and write some more. Assuming you've got the bitcoin source tree cloned the process for adding new tests is easy:

1. Edit src/test/data/script*.json
2. From the src/ directory run:
   make -f makefile.unix test_bitcoin
3. Run the unit tests with:  ./test_bitcoin

Or if you've already got Script test cases in some other human-readable form please point me to them.

I'm planning on resetting the testnet with a new genesis block and a chain that contains all of the valid tests as spent transactions (and a checkpoint so all those nice test cases aren't overwritten).

It would be really nifty to have a 'bad chain' node running; -connect to it and it would send you otherwise-valid blocks that contained one or more of the invalid transactions from script_invalid.json. Does that sound like a project any of you would like to tackle?
Jump to: