Faster Blockchain Implementation for testing?
I'm working on a wallet with a bunch of integration tests. Currently we use RpcBlockchain for testing, but it's very slow. It would be nice if there was a fast Blockchain implementation for testing.
This is also related to #543, I think :)
I actually think this is basically a dupe of #543. It would take some extremely poor implementation decisions for a test blockchain backend to be slow 😄
Which is more complex, implementing bdk::blockchain::Blockchain, or implementing a simple in-memory Bitcoin RPC server that can service requests for RpcBlockchain? If the latter is simpler, then that might be the easiest route to take: Implement an in-memory RPC server with all calls that RpcBlockchain uses, and then use that for testing. This would also be useful outside of bdk, for any project that needs to test against a Bitcoin Core node.
Looking at the calls that RpcBlockchain makes, I'm not sure if implementing a dummy RpcClient would be easy:
getaddressinfo
getblockchaininfo
getindexinfo
getnetworkinfo
getwalletinfo
listtransactions
listunspent
listwalletdir
listwallets
sendrawtransaction
setlabel
The main problem with dummy RPC blockchain is not the interface imo (which although is a big task) but simulating the the core's validation logic. The main use of the blockchain for testing is to check weather transaction stuffs are created as per consensus correctly, more than sending and getting data out.. That might take some significant amount of effort to mock..