Skip to content

Commit

Permalink
feat(ci): adjusts mining-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed May 7, 2024
1 parent acc1c99 commit 88ae416
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 171 deletions.
2 changes: 2 additions & 0 deletions .github/mining-test/bitcoind01.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM kylemanna/bitcoind:latest
CMD ["/usr/local/bin/bitcoind", "-printtoconsole", "-regtest", "-debug", "-server", "-listen", "-port=31591", "-connect=localhost:31592", "-rpcbind=0.0.0.0:32591", "-rpcallowip=0.0.0.0/0", "-rpcuser=admin", "-rpcpassword=admin" ]
2 changes: 2 additions & 0 deletions .github/mining-test/bitcoind02.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM kylemanna/bitcoind:latest
CMD ["/usr/local/bin/bitcoind", "-printtoconsole", "-regtest", "-debug", "-server", "-listen", "-port=31592", "-connect=localhost:31591", "-rpcbind=0.0.0.0:32592", "-rpcallowip=0.0.0.0/0", "-rpcuser=admin", "-rpcpassword=admin" ]
49 changes: 49 additions & 0 deletions .github/mining-test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

sudo docker run -d --name bitcoind01 -p 31591:31591 -p 32591:32591 --entrypoint "/usr/local/bin/bitcoind" kylemanna/bitcoind:latest -printtoconsole -regtest -debug -server -listen -port=31591 -connect=localhost:31592 -rpcbind=0.0.0.0:32591 -rpcallowip=0.0.0.0/0 -rpcuser=admin -rpcpassword=admin
sudo docker run -d --name bitcoind02 -p 31592:31592 -p 32592:32592 --entrypoint "/usr/local/bin/bitcoind" kylemanna/bitcoind:latest -printtoconsole -regtest -debug -server -listen -port=31592 -connect=localhost:31591 -rpcbind=0.0.0.0:32592 -rpcallowip=0.0.0.0/0 -rpcuser=admin -rpcpassword=admin

while ! docker ps --format "{{.Names}}" | grep -wq bitcoind01; do
echo "Waiting for container bitcoind01 to start..."
sleep 5 # Wait for 5 seconds before checking again
done
echo "bitcoind01 container is running."

while ! docker ps --format "{{.Names}}" | grep -wq bitcoind02; do
echo "Waiting for container bitcoind02 to start..."
sleep 5 # Wait for 5 seconds before checking again
done
echo "bitcoind02 container is running."

docker network ls
ports=(31591 32591 31592 32592)
for port in "${ports[@]}"; do
if ! sudo lsof -i:$port -sTCP:LISTEN > /dev/null; then
echo "Error: No process is listening on port $port"
exit 1
fi
done
echo "Success: All specified ports are being listened to."

echo Test bitcoin node 1
curl -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32591 --fail
if [ $? -ne 0 ]; then
echo "Error: Failed to connect to the Bitcoin bitcoind01 node"
exit 1
fi
echo Test bitcoin node 2
curl -s -u admin:admin --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockchaininfo","params":[]}' -H 'content-type:text/plain;' http://localhost:32592 --fail
if [ $? -ne 0 ]; then
echo "Error: Failed to connect to the Bitcoin bitcoind02 node"
exit 1
fi

echo "Linking btc nodes to localhost"
echo "127.0.0.1 bitcoind01" | sudo tee -a /etc/host > /dev/null
echo "127.0.0.1 bitcoind02" | sudo tee -a /etc/host > /dev/null
echo "/etc/hosts"
cat /etc/hosts

echo "Generate BTC blocks"
(cd mining-integration-tests && node generateBtcBlocks.js || exit 1)

Loading

0 comments on commit 88ae416

Please sign in to comment.