Testing¶
At the moment most tests rely on a bitcoin regtest node running. Depending on how the bitcoin node is run some environment variables may need to be set.
The simplest is to use the provided docker-compose.yml under the
pyspool
github repository.
First run the bitcoin regtest daemon in background mode:
$ docker-compose up -d bitcoin
Then run the tests:
$ docker-compose run --rm spool py.test -v
To run the tests against python 2:
$ docker-compose run --rm spool-py2 py.test -v
Note
You may need to build the image for the services spool
and
spool-py2
. E.g.:
$ docker-compose build spool
Without Docker¶
The tests rely on four environment variables specific to bitcoin:
-
BITCOIN_HOST
¶ The host of the bitcoin regtest node. Defaults to
'localhost'
.
-
BITCOIN_PORT
¶ The port of the bitcoin regtest node. Defaults to
18332
.
-
BITCOIN_RPCUSER
¶ The rpc user used to connect to bitcoin regtest node. Defaults to
'merlin'
.
-
BITCOIN_RPCPASSWORD
¶ The password of the user, used to connect to the bitcoin regtest node. Defaults to
'secret'
.
Assuming the above default environment variables, a bitcoin regtest node can be run as follows:
$ bitcoind -daemon -regtest -rpcuser=merlin -rpcpassword=secret -txindex=1
Important
Please note the -txindex=1
option. This ensures that all
transactions are indexed and retrievable by the RPC
getrawtransaction
. Without this option some tests will fail.
Using a bitcoin.conf
¶
A bitcoin.conf file can also be used. E.g.:
# $HOME/.bitcoin/bitcoin.conf (under linux)
rpcuser=merlin
rpcpassword=secret
txindex=1
Tip
The .travis.yml, docker-compose.yml, and bitcoin_regtest.conf
files, under the pyspool
github repository may be helpful to look at.