Integration testing for BitCoin [combined summary]



Individual post summaries: Click here to read the original discussion on the bitcoin-dev mailing list

Published on: 2013-04-07T13:50:01+00:00


Summary:

Adam Ritter and Gregory Maxwell, members of the Bitcoin community, have discussed the importance of integration testing for Bitcoin's future development. Ritter emphasized the need to make the code more stable and test attack scenarios, refactoring, and extending code. Maxwell suggested calling these tests "system tests" and recommended using blocktester, a system based on BitcoinJ that simulates a peer against a slightly instrumented copy of Bitcoin (d/-qt). Blocktester runs complicated network scenarios and tests the boundaries of blockchain validation protocol rules, and is used as part of the automated tests on every proposed patch to the reference software.Integration tests are also necessary in bitcoinj to exercise the wallet code. In the past, unit tests were not realistic enough and did not simulate real network scenarios, resulting in bugs. Integration tests should handle re-orgs correctly and update the wallet properly in all cases. Additionally, a standalone tool that stress-tests the system would be useful to catch bugs earlier. This tool could randomly generate chains of transactions and could be written using bitcoinj or the raw transaction APIs on bitcoind.Blocktester, developed by Matt Corallo, is used for system testing in BitcoinJ. It simulates a peer against a slightly instrumented copy of Bitcoin(d/-qt) and tests complicated network scenarios while boundary testing many rules of the blockchain validation protocol. These tests are run as part of the automated tests on every proposed patch to the reference software, and pulltester comments on GitHub requests and produces logs.There is also a public secondary test network called 'testnet', which operates the same as the production network except it allows mining low difficulty blocks to prevent it from going for long times without blocks. Most of the testing work has focused on validating blockchain behavior because it has serious systemic risk, but measuring the JSON-RPC behavior is also interesting.Adam Ritter expressed concerns about the lack of integration tests for Bitcoin and the need to make the code more stable. Gregory Maxwell preferred calling these tests system tests and shared the use of blocktester in BitcoinJ to simulate network scenarios and test blockchain validation protocol rules. These tests are run as part of automated tests on every proposed patch to the reference software. Additionally, a public secondary test network called Testnet is available for testing purposes. Most of the testing work has been focused on validating blockchain behavior due to its systemic risk. The proposed integration testing aims to make the code easier to refactor and extend while ensuring it doesn't break the overall behavior of the client. It will also allow testing of attack scenarios and support multiple coins without breaking the original BitCoin protocol. The implementation will use the JSON-RPC interface and be written in C++, with the second implementation leveraging the BitCoin code directly by refactoring the client as a library. Dependency injection will be used for time and verifying mined blocks to enable faster running of tests without using real CPU power for mining.


Updated on: 2023-08-01T04:37:20.972200+00:00