Skip to main content

bitcoind mock

tippin.me

bitcoind mock is an approach to simulate bitcoind for unit testing. It is specially useful for Continuous integration (CI) tools.

The mock provides a JSON-RPC interface with some of the RPC commands available in bitcoind along with a zmq interface for transaction and block notification. The mock also provides additional endpoints to generate blocks on demand (/generate) and to create forks (/fork).

The mock can be run either by time, where blocks will be generated in fix time intervals, or by events where a block will be generated each time /generate is called.

This are the current partially covered commands:

decoderawtransaction:   querying for the decoding of a raw transaction will return a dictionary with a single
                        field: "txid".

sendrawtransaction:     sending a rawtransaction will notify our mining simulator to include such transaction in
                        a subsequent block (add it to mempool).

getrawtransaction:      requesting a rawtransaction from a txid will return a dictionary containing a single
                        field: "confirmations", since rawtransactions are only queried to check whether a
                        transaction has made it to a block or not.

getblockcount:          the block count represents the length of the longest chain.

getblock:               querying for a block will return a dictionary with three fields: "tx" representing a
                        list of transactions, "height" representing the block height and "hash" representing the
                        block hash.

getblockhash:           returns the hash of a block given its height.

getbestblockhash:       returns the hash of the block in the tip of the chain.

help:                   help is only used as a sample command to test if bitcoind is running when bootstrapping.
                        It will return a 200/OK with no data.

Known limitations

  • The implemented commands do not return every single field that bitcoind would, only the most important ones (or the ones that I've required so for my own unit tests).

  • The mock works well when interacting with via python but not if queried directly by bitcoin-cli (check #1).

  • zmq only notifies about blocks being mined, but not about transactions.

  • Requesting a fork while running the mock by time will not reset the timer for the block that will be mined on top of the forked one.

Dependencies

Refer to DEPENCENCIES.md.

Installation

You can get the package from PyPi:

pip install bitcoind-mock

Or install it manually (refer to INSTALL.md).

Contributing

If you'd like to add / extend any command, feel free to send a PR. We can make this as complete as we'd like by joining efforts :smile:

Refer to CONTRIBUTING.md for the style guidelines to follow.

Metadata

Release files for bitcoind-mock 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bitcoind-mock 0.0.5
File Size Uploaded Provenance Actions
bitcoind_mock-0.0.5.tar.gz 15.6 kB Without provenance Details for bitcoind_mock-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bitcoind-mock 0.0.5
File Interpreter ABI Platform Actions
bitcoind_mock-0.0.5-py3-none-any.whl Python 3 none any Details for bitcoind_mock-0.0.5-py3-none-any.whl

Total release size: 34.6 kB

Release files / bitcoind_mock-0.0.5.tar.gz

Download URL bitcoind_mock-0.0.5.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
16924ade3886b663420d60551c22fbf5a5a6f0492710ee7073fc8a87866fa2b8
BLAKE2b-256 checksum
How to use checksums
4be0bf654574b8700303692d4caded955c38443e4568ed5fdace85d75f09b775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.7

Release files / bitcoind_mock-0.0.5-py3-none-any.whl

Download URL bitcoind_mock-0.0.5-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29217ae8ea3342c4614da1e3c629d04ec4317c44535553e8b5aa486de9d512e0
BLAKE2b-256 checksum
How to use checksums
92aa3e0193051fdfbca082158896d6d2590617aad36b5cadeb05d3e3250db0c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.7

Security for bitcoind-mock 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page