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 75fa690
Show file tree
Hide file tree
Showing 2 changed files with 344 additions and 169 deletions.
76 changes: 76 additions & 0 deletions .github/mining-test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

#echo "create docker network for bitcoin nodes exposing it to host"
#sudo docker network create bitcoin-network
#docker network ls
#docker network inspect bitcoin-network
#docker network connect bitcoin-network bitcoind01
#docker network connect bitcoin-network bitcoind02

#sudo docker run -d --network bitcoin-network --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 --network bitcoin-network --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

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

#echo "Verify nodes are attached to the network"
#docker network ls
#docker network inspect bitcoin-network
#if ! docker network inspect bitcoin-network | grep -q "\"Name\": \"bitcoind01\""; then
# echo "bitcoind01 is not on the network"
# exit 1
#fi
#if ! docker network inspect bitcoin-network | grep -q "\"Name\": \"bitcoind02\""; then
# echo "bitcoind02 is not on the network"
# exit 1
#fi

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
#echo "127.0.0.1 bitcoind02" | sudo tee -a /etc/host
#echo "/etc/hosts"
#cat /etc/hosts

echo "Modify test suite config"
cat mining-integration-tests/config.json
jq --arg new_url "localhost" '.bitcoind.url = $new_url' "mining-integration-tests/config.json" > temp.json && mv temp.json "mining-integration-tests/config.json"
cat mining-integration-tests/config.json

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

Loading

0 comments on commit 75fa690

Please sign in to comment.