# Gavin Andresen # 2011-07-05 21:06:13 # https://bitcointalk.org/index.php?topic=26327.msg328773#msg328773 I'm thinking about how to do higher-level testing of bitcoin, and I think we could get a lot of mileage out of a testing harness that works at the network protocol level. @p{par} I'm thinking of testing things like proper handling of block chain re-orgs and valid and invalid transactions. @p{par} Examples: @p{par} @p{(bf}Block chain re-org test:@p{bf)} @p{brk} @p{(li}Start a bitcoin client with an empty wallet and just the genesis block, -noirc listening on a non-standard port.@p{li)} @p{(li}test harness connects, then feeds it a pre-canned block chain @p{brk} ... then sends it a longer fork@p{li)} @p{(li}test harness makes sure client accepted the longer chain by sending it a getblocks messsage @p{brk} (or disconnects and re-connects and checks the start_height in the version message) @p{brk} @p{li)} @p{brk} @p{(bf}Valid/invalid transaction tests@p{bf)} @p{brk} @p{(li}Start bitcoin client as above@p{li)} @p{(li}test harness connects, sends a series of valid and invalid transactions (via inv message and then responding to getdata).@p{li)} @p{(li}test harness checks to see if transactions were accepted or rejected by checking responses to getdata (should be no response for invalid transactions)@p{li)} @p{brk} @p{hrule} A set of good data files with "tx" and "block" (and "inv" and all the rest) messages in them, combined with something like @p{(link}pexpect@p{link)} could make a good test system. I'm thinking they should be human-readable (with a proxy listening tool or wireshark plugin or something that dumps bitcoin protocol into the human-readable form) but pretty low-level; maybe @p{(link}a version message@p{link)} looks like: @p{brk} Code: { "version" : [ "u32:31900", "i64:1", "i64:1309899496", "addr:127.0.0.1:8333", "addr:127.0.0.1:5432", "u64:1235876", "s:", "i32:98645" ] } @p{brk} @p{par} So, before I start working on something like this: Anybody already doing something similar?