bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Faster Blockchain Implementation for testing?

Open casey opened this issue 3 years ago • 5 comments

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.

casey avatar Jul 29 '22 21:07 casey

This is also related to #543, I think :)

danielabrozzoni avatar Jul 30 '22 07:07 danielabrozzoni

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 😄

casey avatar Jul 30 '22 07:07 casey

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.

casey avatar Aug 01 '22 17:08 casey

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

casey avatar Aug 01 '22 17:08 casey

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..

rajarshimaitra avatar Aug 15 '22 14:08 rajarshimaitra