Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ cache:

before_install:
- git clone https://github.com/bitcoin-core/secp256k1.git
- sudo apt-add-repository ppa:bitcoin/bitcoin -y
- sudo apt-get update
- mkdir bin
- wget https://bitcoincore.org/bin/bitcoin-core-0.20.0/bitcoin-0.20.0-x86_64-linux-gnu.tar.gz
- echo "35ec10f87b6bc1e44fd9cd1157e5dfa483eaf14d7d9a9c274774539e7824c427 bitcoin-0.20.0-x86_64-linux-gnu.tar.gz" | sha256sum --check
- tar -xzvf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz
- mv ./bitcoin-0.20.0/bin/bitcoind ./bin/bitcoind
- wget https://download.bitcoinabc.org/0.18.5/linux/bitcoin-abc-0.18.5-x86_64-linux-gnu.tar.gz
- echo "11439fcdae421ae96d2a7ddc3d43c9c284af44716cb5f363c61e53885a5a8811 bitcoin-abc-0.18.5-x86_64-linux-gnu.tar.gz" | sha256sum --check
- tar -xzvf bitcoin-abc-0.18.5-x86_64-linux-gnu.tar.gz
- mv ./bitcoin-abc-0.18.5/bin/bitcoind ./bin/bitcoin-cash
- wget https://download.litecoin.org/litecoin-0.18.1/linux/litecoin-0.18.1-x86_64-linux-gnu.tar.gz
- echo "ca50936299e2c5a66b954c266dcaaeef9e91b2f5307069b9894048acf3eb5751 litecoin-0.18.1-x86_64-linux-gnu.tar.gz" | sha256sum --check
- tar -xzvf litecoin-0.18.1-x86_64-linux-gnu.tar.gz
- mv ./litecoin-0.18.1/bin/litecoind ./bin/litecoind

install:
- sudo apt-get install build-essential automake pkg-config libtool libgmp-dev bitcoind -y
- sudo apt-get install build-essential automake pkg-config libtool libgmp-dev -y
- pip install -r requirements.txt
- cd secp256k1
- ./autogen.sh
Expand All @@ -29,7 +37,8 @@ install:
- export LD_LIBRARY_PATH

script:
- python generate_chain.py --output-dir=.output --chain=btc
- python generate_chain.py --output-dir=.output --chain=btc --exec=./bin/bitcoind
- python generate_chain.py --output-dir=.output --chain=bch --exec=./bin/bitcoin-cash
- python generate_chain.py --output-dir=.output --chain=ltc --exec=./bin/litecoind
- cd tests && pytest

1 change: 1 addition & 0 deletions bitcoin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ server=1
regtest=1
rpcuser=rpcuser
rpcpassword=rpcpassword
dustrelayfee=0
2 changes: 1 addition & 1 deletion runall.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
python3 generate_chain.py --output-dir=output
python3 generate_chain.py --output-dir=output --chain=btc --exec=./bin/bitcoind
python3 generate_chain.py --output-dir=output --chain=bch --exec=./bin/bitcoin-cash
python3 generate_chain.py --output-dir=output --chain=ltc --exec=./bin/litecoind
25 changes: 20 additions & 5 deletions testchain/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _setup_chain_params(self):
bitcointx.SelectAlternativeParams(CoreLitecoinParams, RegtestLitecoinParams)

def _setup_bitcoind(self):
self.tempdir = tempfile.TemporaryDirectory()
self.tempdir = tempfile.TemporaryDirectory(prefix="testchain-generator-")
self.log.info("datadir: {}".format(self.tempdir.name))

if self.chain == "btc" or self.chain == "bch":
Expand Down Expand Up @@ -80,16 +80,31 @@ def _setup_bitcoind(self):
# kill process when generator is done
atexit.register(self._terminate)

self.log.info("Waiting 10 seconds for node to start")
sleep(10)
# Call a common RPC i.e. `getblockcount` to check if node is started
self.log.info("Waiting up to 10 seconds for node to start")
for _ in range(10):
tmp_proxy = bitcointx.rpc.Proxy(btc_conf_file=self.conf_file)
try:
tmp_proxy.getblockcount()
break
except (ConnectionRefusedError, bitcointx.rpc.InWarmupError):
sleep(1)
# ... and try again
finally:
tmp_proxy.close()

def _terminate(self):
"""
Kills the bitcoind process
"""
self.proxy.close() # Close connection so the node don't have to wait
self.proc.terminate()
self.log.info("Waiting 5 seconds for node to quit")
sleep(5)
self.log.info("Waiting up to 10 seconds for node to quit...")
try:
self.proc.wait(10)
except subprocess.TimeoutExpired:
self.log.info("Could not terminate node, killing...")
self.proc.kill()

def next_timestamp(self):
self.current_time += 600
Expand Down