mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-01-31 18:24:26 +01:00
Cleanups, fix pid1 in containers, use proxy_ready monitor
This commit is contained in:
@@ -76,7 +76,7 @@ main() {
|
||||
case "${cmd}" in
|
||||
helloworld)
|
||||
# GET http://192.168.111.152:8080/helloworld
|
||||
response="Hello, world!"
|
||||
response='{"hello":"world"}'
|
||||
returncode=0
|
||||
# response_to_client "Hello, world!" 0
|
||||
# break
|
||||
@@ -774,11 +774,6 @@ main() {
|
||||
return 0
|
||||
}
|
||||
|
||||
export NODE_RPC_URL=$BTC_NODE_RPC_URL
|
||||
export TRACING
|
||||
export DB_PATH
|
||||
export DB_FILE
|
||||
|
||||
main
|
||||
trace "[requesthandler] exiting"
|
||||
exit $?
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
send_to_watcher_node() {
|
||||
trace "Entering send_to_watcher_node()..."
|
||||
local node_payload
|
||||
node_payload="$(send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET} ${WATCHER_NODE_RPC_CFG} $@)"
|
||||
node_payload="$(send_to_bitcoin_node ${WATCHER_BTC_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET} ${WATCHER_BTC_NODE_RPC_CFG} $@)"
|
||||
local returncode=$?
|
||||
trace_rc ${returncode}
|
||||
if [ "${returncode}" -ne 0 ]; then
|
||||
@@ -22,7 +22,7 @@ send_to_watcher_node() {
|
||||
send_to_xpub_watcher_wallet() {
|
||||
trace "Entering send_to_xpub_watcher_wallet()..."
|
||||
|
||||
send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${WATCHER_BTC_NODE_XPUB_WALLET} ${WATCHER_NODE_RPC_CFG} $@
|
||||
send_to_bitcoin_node ${WATCHER_BTC_NODE_RPC_URL}/${WATCHER_BTC_NODE_XPUB_WALLET} ${WATCHER_BTC_NODE_RPC_CFG} $@
|
||||
local returncode=$?
|
||||
trace_rc ${returncode}
|
||||
return ${returncode}
|
||||
@@ -33,7 +33,7 @@ send_to_watcher_node_wallet() {
|
||||
local walletname=$1
|
||||
shift
|
||||
trace "[send_to_watcher_node_wallet] walletname=${walletname}"
|
||||
send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${walletname} ${WATCHER_NODE_RPC_CFG} $@
|
||||
send_to_bitcoin_node ${WATCHER_BTC_NODE_RPC_URL}/${walletname} ${WATCHER_BTC_NODE_RPC_CFG} $@
|
||||
local returncode=$?
|
||||
trace_rc ${returncode}
|
||||
return ${returncode}
|
||||
@@ -42,7 +42,7 @@ send_to_watcher_node_wallet() {
|
||||
send_to_spender_node()
|
||||
{
|
||||
trace "Entering send_to_spender_node()..."
|
||||
send_to_bitcoin_node ${SPENDER_NODE_RPC_URL}/${SPENDER_BTC_NODE_DEFAULT_WALLET} ${SPENDER_NODE_RPC_CFG} $@
|
||||
send_to_bitcoin_node ${SPENDER_BTC_NODE_RPC_URL}/${SPENDER_BTC_NODE_DEFAULT_WALLET} ${SPENDER_BTC_NODE_RPC_CFG} $@
|
||||
local returncode=$?
|
||||
trace_rc ${returncode}
|
||||
return ${returncode}
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
export PROXY_LISTENING_PORT
|
||||
export WATCHER_NODE_RPC_URL=$WATCHER_BTC_NODE_RPC_URL
|
||||
export SPENDER_NODE_RPC_URL=$SPENDER_BTC_NODE_RPC_URL
|
||||
export WATCHER_NODE_RPC_CFG=$WATCHER_BTC_NODE_RPC_CFG
|
||||
export SPENDER_NODE_RPC_CFG=$SPENDER_BTC_NODE_RPC_CFG
|
||||
export TRACING
|
||||
export DB_PATH
|
||||
export DB_FILE
|
||||
|
||||
trim() {
|
||||
echo -e "$1" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'
|
||||
}
|
||||
@@ -51,4 +42,4 @@ if [ "${FEATURE_LIGHTNING}" = "true" ]; then
|
||||
./waitanyinvoice.sh &
|
||||
fi
|
||||
|
||||
nc -vlkp${PROXY_LISTENING_PORT} -e ./requesthandler.sh
|
||||
exec nc -vlkp${PROXY_LISTENING_PORT} -e ./requesthandler.sh
|
||||
|
||||
@@ -38,6 +38,16 @@ exec_in_test_container() {
|
||||
docker exec -it tests-manage-missed $@
|
||||
}
|
||||
|
||||
wait_for_proxy() {
|
||||
trace 1 "\n\n[wait_for_proxy] ${BCyan}Waiting for the proxy to be ready...${Color_Off}\n"
|
||||
|
||||
# First ping the containers to make sure they're up...
|
||||
docker exec -t tests-manage-missed sh -c 'while true ; do ping -c 1 proxy ; [ "$?" -eq "0" ] && break ; sleep 5; done'
|
||||
|
||||
# Now check if the lightning nodes are ready to accept requests...
|
||||
docker exec -t tests-manage-missed sh -c 'while true ; do curl proxy:8888/helloworld ; [ "$?" -eq "0" ] && break ; sleep 5; done'
|
||||
}
|
||||
|
||||
test_manage_missed_0_conf() {
|
||||
# Missed 0-conf:
|
||||
# 1. Get new address
|
||||
@@ -69,9 +79,8 @@ test_manage_missed_0_conf() {
|
||||
docker exec -it $(docker ps -q -f "name=cyphernode_bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address} 0.0001
|
||||
# txid1=$(exec_in_test_container curl -d '{"address":"'${address}'","amount":0.0001}' proxy:8888/spend | jq -r ".txid")
|
||||
|
||||
trace 3 "[test_manage_missed_0_conf] Sleeping for 10 seconds to let the proxy restart..."
|
||||
sleep 10
|
||||
|
||||
wait_for_proxy
|
||||
|
||||
trace 3 "[test_manage_missed_0_conf] Calling executecallbacks..."
|
||||
exec_in_test_container curl -s -H "Content-Type: application/json" proxy:8888/executecallbacks
|
||||
|
||||
@@ -116,9 +125,8 @@ test_manage_missed_1_conf() {
|
||||
trace 3 "[test_manage_missed_1_conf] Mine a new block..."
|
||||
mine
|
||||
|
||||
trace 3 "[test_manage_missed_1_conf] Sleeping for 10 seconds to let the proxy restart..."
|
||||
sleep 10
|
||||
|
||||
wait_for_proxy
|
||||
|
||||
trace 3 "[test_manage_missed_1_conf] Calling executecallbacks..."
|
||||
exec_in_test_container curl -s -H "Content-Type: application/json" proxy:8888/executecallbacks
|
||||
}
|
||||
@@ -148,8 +156,7 @@ trace 2 "url3=${url3}"
|
||||
trace 2 "url4=${url4}"
|
||||
|
||||
exec_in_test_container apk add --update curl
|
||||
# exec_in_test_container ping -c 5 tests-manage-missed
|
||||
# exec_in_test_container curl -vd 'toto' ${url1}/allo
|
||||
|
||||
test_manage_missed_0_conf
|
||||
test_manage_missed_1_conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user