mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-17 12:45:22 +01:00
Better tests, small fix in computefees, upgraded bitcoin, c-lightning
This commit is contained in:
6
dist/setup.sh
vendored
6
dist/setup.sh
vendored
@@ -855,7 +855,7 @@ SUDO_REQUIRED=0
|
|||||||
AUTOSTART=0
|
AUTOSTART=0
|
||||||
|
|
||||||
# CYPHERNODE VERSION "v0.7.0-dev"
|
# CYPHERNODE VERSION "v0.7.0-dev"
|
||||||
SETUP_VERSION="v0.7.0-dev"
|
SETUP_VERSION="dev-on-v0.7.0"
|
||||||
CONF_VERSION="v0.7.0-dev"
|
CONF_VERSION="v0.7.0-dev"
|
||||||
GATEKEEPER_VERSION="v0.7.0-dev"
|
GATEKEEPER_VERSION="v0.7.0-dev"
|
||||||
TOR_VERSION="v0.7.0-dev"
|
TOR_VERSION="v0.7.0-dev"
|
||||||
@@ -865,8 +865,8 @@ PROXYCRON_VERSION="v0.7.0-dev"
|
|||||||
OTSCLIENT_VERSION="v0.7.0-dev"
|
OTSCLIENT_VERSION="v0.7.0-dev"
|
||||||
PYCOIN_VERSION="v0.7.0-dev"
|
PYCOIN_VERSION="v0.7.0-dev"
|
||||||
CYPHERAPPS_VERSION="dev"
|
CYPHERAPPS_VERSION="dev"
|
||||||
BITCOIN_VERSION="v0.21.1"
|
BITCOIN_VERSION="v22.0"
|
||||||
LIGHTNING_VERSION="v0.10.1"
|
LIGHTNING_VERSION="v0.10.2"
|
||||||
TRAEFIK_VERSION="v1.7.9-alpine"
|
TRAEFIK_VERSION="v1.7.9-alpine"
|
||||||
MOSQUITTO_VERSION="1.6-openssl"
|
MOSQUITTO_VERSION="1.6-openssl"
|
||||||
POSTGRES_VERSION="14.0-alpine"
|
POSTGRES_VERSION="14.0-alpine"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ WORKDIR ${HOME}
|
|||||||
COPY app/data/* ./
|
COPY app/data/* ./
|
||||||
COPY app/script/* ./
|
COPY app/script/* ./
|
||||||
COPY app/tests/* ./tests/
|
COPY app/tests/* ./tests/
|
||||||
COPY --from=cyphernode/clightning:v0.10.1 /usr/local/bin/lightning-cli ./
|
COPY --from=cyphernode/clightning:v0.10.2 /usr/local/bin/lightning-cli ./
|
||||||
COPY --from=eclipse-mosquitto:1.6-openssl /usr/bin/mosquitto_rr /usr/bin/mosquitto_sub /usr/bin/mosquitto_pub /usr/bin/
|
COPY --from=eclipse-mosquitto:1.6-openssl /usr/bin/mosquitto_rr /usr/bin/mosquitto_sub /usr/bin/mosquitto_pub /usr/bin/
|
||||||
COPY --from=eclipse-mosquitto:1.6-openssl /usr/lib/libmosquitto* /usr/lib/
|
COPY --from=eclipse-mosquitto:1.6-openssl /usr/lib/libmosquitto* /usr/lib/
|
||||||
COPY --from=eclipse-mosquitto:1.6-openssl /usr/lib/libcrypto* /usr/lib/
|
COPY --from=eclipse-mosquitto:1.6-openssl /usr/lib/libcrypto* /usr/lib/
|
||||||
|
|||||||
@@ -88,9 +88,7 @@ compute_vin_total_amount()
|
|||||||
sql "INSERT INTO tx (txid, hash, confirmations, timereceived, size, vsize, blockhash, blockheight, blocktime)"\
|
sql "INSERT INTO tx (txid, hash, confirmations, timereceived, size, vsize, blockhash, blockheight, blocktime)"\
|
||||||
" VALUES ('${vin_txid}', '${vin_hash}', ${vin_confirmations}, ${vin_timereceived}, ${vin_size}, ${vin_vsize}, '${vin_blockhash}', ${vin_blockheight}, ${vin_blocktime})"\
|
" VALUES ('${vin_txid}', '${vin_hash}', ${vin_confirmations}, ${vin_timereceived}, ${vin_size}, ${vin_vsize}, '${vin_blockhash}', ${vin_blockheight}, ${vin_blocktime})"\
|
||||||
" ON CONFLICT (txid) DO"\
|
" ON CONFLICT (txid) DO"\
|
||||||
" UPDATE SET blockhash='${vin_blockhash}', blockheight=${vin_blockheight}, blocktime=${vin_blocktime}, confirmations=${vin_confirmations}"\
|
" UPDATE SET blockhash='${vin_blockhash}', blockheight=${vin_blockheight}, blocktime=${vin_blocktime}, confirmations=${vin_confirmations}"
|
||||||
" RETURNING id" \
|
|
||||||
"SELECT id FROM tx WHERE txid='${vin_txid}'"
|
|
||||||
trace_rc $?
|
trace_rc $?
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# docker exec -it $(docker ps -q -f "name=proxy\.") ./tests/test-batching.sh
|
. ./colors.sh
|
||||||
|
|
||||||
# This needs to be run in regtest
|
# This needs to be run in regtest
|
||||||
|
# You need jq installed for these tests to run correctly
|
||||||
|
|
||||||
# This will test:
|
# This will test:
|
||||||
#
|
#
|
||||||
@@ -22,23 +23,48 @@
|
|||||||
|
|
||||||
|
|
||||||
# Notes:
|
# Notes:
|
||||||
# curl localhost:8888/listbatchers | jq
|
# curl proxy:8888/listbatchers | jq
|
||||||
# curl -d '{}' localhost:8888/getbatcher | jq
|
# curl -d '{}' proxy:8888/getbatcher | jq
|
||||||
# curl -d '{}' localhost:8888/getbatchdetails | jq
|
# curl -d '{}' proxy:8888/getbatchdetails | jq
|
||||||
# curl -d '{"outputLabel":"test002","address":"1abd","amount":0.0002}' localhost:8888/addtobatch | jq
|
# curl -d '{"outputLabel":"test002","address":"1abd","amount":0.0002}' proxy:8888/addtobatch | jq
|
||||||
# curl -d '{}' localhost:8888/batchspend | jq
|
# curl -d '{}' proxy:8888/batchspend | jq
|
||||||
# curl -d '{"outputId":1}' localhost:8888/removefrombatch | jq
|
# curl -d '{"outputId":1}' proxy:8888/removefrombatch | jq
|
||||||
|
|
||||||
# curl -d '{"batcherLabel":"lowfees","confTarget":32}' localhost:8888/createbatcher | jq
|
# curl -d '{"batcherLabel":"lowfees","confTarget":32}' proxy:8888/createbatcher | jq
|
||||||
# curl localhost:8888/listbatchers | jq
|
# curl proxy:8888/listbatchers | jq
|
||||||
|
|
||||||
|
# curl -d '{"batcherLabel":"lowfees"}' proxy:8888/getbatcher | jq
|
||||||
|
# curl -d '{"batcherLabel":"lowfees"}' proxy:8888/getbatchdetails | jq
|
||||||
|
# curl -d '{"batcherLabel":"lowfees","outputLabel":"test002","address":"1abd","amount":0.0002}' proxy:8888/addtobatch | jq
|
||||||
|
# curl -d '{"batcherLabel":"lowfees"}' proxy:8888/batchspend | jq
|
||||||
|
# curl -d '{"batcherLabel":"lowfees","outputId":9}' proxy:8888/removefrombatch | jq
|
||||||
|
|
||||||
|
|
||||||
|
trace() {
|
||||||
|
if [ "${1}" -le "${TRACING}" ]; then
|
||||||
|
echo "$(date -u +%FT%TZ) ${2}" 1>&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_test_container() {
|
||||||
|
docker run -d --rm -it --name tests-batching --network=cyphernodenet alpine
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_test_container() {
|
||||||
|
trace 1 "\n\n[stop_test_container] ${BCyan}Stopping existing containers if they are running...${Color_Off}\n"
|
||||||
|
|
||||||
|
docker stop tests-batching
|
||||||
|
docker stop tests-batching-cb
|
||||||
|
}
|
||||||
|
|
||||||
|
exec_in_test_container() {
|
||||||
|
docker exec -it tests-batching "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# curl -d '{"batcherLabel":"lowfees"}' localhost:8888/getbatcher | jq
|
|
||||||
# curl -d '{"batcherLabel":"lowfees"}' localhost:8888/getbatchdetails | jq
|
|
||||||
# curl -d '{"batcherLabel":"lowfees","outputLabel":"test002","address":"1abd","amount":0.0002}' localhost:8888/addtobatch | jq
|
|
||||||
# curl -d '{"batcherLabel":"lowfees"}' localhost:8888/batchspend | jq
|
|
||||||
# curl -d '{"batcherLabel":"lowfees","outputId":9}' localhost:8888/removefrombatch | jq
|
|
||||||
|
|
||||||
testbatching() {
|
testbatching() {
|
||||||
|
trace 1 "\n\n[testbatching] ${BCyan}Let's test batching features!...${Color_Off}\n"
|
||||||
|
|
||||||
local response
|
local response
|
||||||
local id
|
local id
|
||||||
local id2
|
local id2
|
||||||
@@ -55,41 +81,41 @@ testbatching() {
|
|||||||
echo "url2=${url2}"
|
echo "url2=${url2}"
|
||||||
|
|
||||||
# List batchers (should show at least empty default batcher)
|
# List batchers (should show at least empty default batcher)
|
||||||
echo "Testing listbatchers..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing listbatchers...${Color_Off}\n"
|
||||||
response=$(curl -s proxy:8888/listbatchers)
|
response=$(exec_in_test_container curl -s proxy:8888/listbatchers)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id=$(echo "${response}" | jq ".result[0].batcherId")
|
id=$(echo "${response}" | jq ".result[0].batcherId")
|
||||||
echo "batcherId=${id}"
|
trace 3 "[testbatching] batcherId=${id}"
|
||||||
if [ "${id}" -ne "1" ]; then
|
if [ "${id}" -ne "1" ]; then
|
||||||
exit 10
|
exit 10
|
||||||
fi
|
fi
|
||||||
echo "Tested listbatchers."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested listbatchers.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatcher the default batcher
|
# getbatcher the default batcher
|
||||||
echo "Testing getbatcher..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatcher...${Color_Off}\n"
|
||||||
response=$(curl -sd '{}' localhost:8888/getbatcher)
|
response=$(exec_in_test_container curl -sd '{}' proxy:8888/getbatcher)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
trace 3 "[testbatching] batcherLabel=${data}"
|
||||||
if [ "${data}" != "default" ]; then
|
if [ "${data}" != "default" ]; then
|
||||||
exit 20
|
exit 20
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"batcherId":1}' localhost:8888/getbatcher)
|
response=$(exec_in_test_container curl -sd '{"batcherId":1}' proxy:8888/getbatcher)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
trace 3 "[testbatching] batcherLabel=${data}"
|
||||||
if [ "${data}" != "default" ]; then
|
if [ "${data}" != "default" ]; then
|
||||||
exit 25
|
exit 25
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatcher."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatcher.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatchdetails the default batcher
|
# getbatchdetails the default batcher
|
||||||
echo "Testing getbatchdetails..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatchdetails...${Color_Off}\n"
|
||||||
response=$(curl -sd '{}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
trace 3 "[testbatching] batcherLabel=${data}"
|
||||||
if [ "${data}" != "default" ]; then
|
if [ "${data}" != "default" ]; then
|
||||||
exit 30
|
exit 30
|
||||||
fi
|
fi
|
||||||
@@ -98,10 +124,10 @@ testbatching() {
|
|||||||
exit 32
|
exit 32
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"batcherId":1}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{"batcherId":1}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
trace 3 "[testbatching] batcherLabel=${data}"
|
||||||
if [ "${data}" != "default" ]; then
|
if [ "${data}" != "default" ]; then
|
||||||
exit 35
|
exit 35
|
||||||
fi
|
fi
|
||||||
@@ -109,16 +135,16 @@ testbatching() {
|
|||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 37
|
exit 37
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||||
|
|
||||||
# addtobatch to default batcher
|
# addtobatch to default batcher
|
||||||
echo "Testing addtobatch..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing addtobatch...${Color_Off}\n"
|
||||||
address1=$(curl -s localhost:8888/getnewaddress | jq -r ".address")
|
address1=$(exec_in_test_container curl -s proxy:8888/getnewaddress | jq -r ".address")
|
||||||
echo "address1=${address1}"
|
trace 3 "[testbatching] address1=${address1}"
|
||||||
response=$(curl -sd '{"outputLabel":"test001","address":"'${address1}'","amount":0.001}' localhost:8888/addtobatch)
|
response=$(exec_in_test_container curl -sd '{"outputLabel":"test001","address":"'${address1}'","amount":0.001}' proxy:8888/addtobatch)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id=$(echo "${response}" | jq ".result.batcherId")
|
id=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id}"
|
trace 3 "[testbatching] batcherId=${id}"
|
||||||
if [ "${id}" -ne "1" ]; then
|
if [ "${id}" -ne "1" ]; then
|
||||||
exit 40
|
exit 40
|
||||||
fi
|
fi
|
||||||
@@ -126,14 +152,14 @@ testbatching() {
|
|||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 42
|
exit 42
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id}"
|
trace 3 "[testbatching] outputId=${id}"
|
||||||
|
|
||||||
address2=$(curl -s localhost:8888/getnewaddress | jq -r ".address")
|
address2=$(exec_in_test_container curl -s proxy:8888/getnewaddress | jq -r ".address")
|
||||||
echo "address2=${address2}"
|
trace 3 "[testbatching] address2=${address2}"
|
||||||
response=$(curl -sd '{"batcherId":1,"outputLabel":"test002","address":"'${address2}'","amount":22000000}' localhost:8888/addtobatch)
|
response=$(exec_in_test_container curl -sd '{"batcherId":1,"outputLabel":"test002","address":"'${address2}'","amount":22000000}' proxy:8888/addtobatch)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id2=$(echo "${response}" | jq ".result.batcherId")
|
id2=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id2}"
|
trace 3 "[testbatching] batcherId=${id2}"
|
||||||
if [ "${id2}" -ne "1" ]; then
|
if [ "${id2}" -ne "1" ]; then
|
||||||
exit 47
|
exit 47
|
||||||
fi
|
fi
|
||||||
@@ -141,115 +167,104 @@ testbatching() {
|
|||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 50
|
exit 50
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id2}"
|
trace 3 "[testbatching] outputId=${id2}"
|
||||||
echo "Tested addtobatch."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested addtobatch.${Color_Off}\n"
|
||||||
|
|
||||||
# batchspend default batcher
|
# batchspend default batcher
|
||||||
echo "Testing batchspend..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing batchspend...${Color_Off}\n"
|
||||||
response=$(curl -sd '{}' localhost:8888/batchspend)
|
response=$(exec_in_test_container curl -sd '{}' proxy:8888/batchspend)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
echo "${response}" | jq -e ".error"
|
echo "${response}" | jq -e ".error"
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 55
|
exit 55
|
||||||
fi
|
fi
|
||||||
echo "Tested batchspend."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested batchspend.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatchdetails the default batcher
|
# getbatchdetails the default batcher
|
||||||
echo "Testing getbatchdetails..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatchdetails...${Color_Off}\n"
|
||||||
response=$(curl -sd '{}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq ".result.nbOutputs")
|
data=$(echo "${response}" | jq ".result.nbOutputs")
|
||||||
echo "nbOutputs=${data}"
|
trace 3 "[testbatching] nbOutputs=${data}"
|
||||||
echo "Tested getbatchdetails."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||||
|
|
||||||
# removefrombatch from default batcher
|
# removefrombatch from default batcher
|
||||||
echo "Testing removefrombatch..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing removefrombatch...${Color_Off}\n"
|
||||||
response=$(curl -sd '{"outputId":'${id}'}' localhost:8888/removefrombatch)
|
response=$(exec_in_test_container curl -sd '{"outputId":'${id}'}' proxy:8888/removefrombatch)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id=$(echo "${response}" | jq ".result.batcherId")
|
id=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id}"
|
trace 3 "[testbatching] batcherId=${id}"
|
||||||
if [ "${id}" -ne "1" ]; then
|
if [ "${id}" -ne "1" ]; then
|
||||||
exit 60
|
exit 60
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"outputId":'${id2}'}' localhost:8888/removefrombatch)
|
response=$(exec_in_test_container curl -sd '{"outputId":'${id2}'}' proxy:8888/removefrombatch)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id=$(echo "${response}" | jq ".result.batcherId")
|
id=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${id}"
|
trace 3 "[testbatching] batcherId=${id}"
|
||||||
if [ "${id}" -ne "1" ]; then
|
if [ "${id}" -ne "1" ]; then
|
||||||
exit 64
|
exit 64
|
||||||
fi
|
fi
|
||||||
echo "Tested removefrombatch."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested removefrombatch.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatchdetails the default batcher
|
# getbatchdetails the default batcher
|
||||||
echo "Testing getbatchdetails..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatchdetails...${Color_Off}\n"
|
||||||
response=$(curl -sd '{"batcherId":1}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{"batcherId":1}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data2=$(echo "${response}" | jq ".result.nbOutputs")
|
data2=$(echo "${response}" | jq ".result.nbOutputs")
|
||||||
echo "nbOutputs=${data2}"
|
trace 3 "[testbatching] nbOutputs=${data2}"
|
||||||
if [ "${data2}" -ne "$((${data}-2))" ]; then
|
if [ "${data2}" -ne "$((${data}-2))" ]; then
|
||||||
exit 68
|
exit 68
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Create a batcher
|
# Create a batcher
|
||||||
echo "Testing createbatcher..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing createbatcher...${Color_Off}\n"
|
||||||
response=$(curl -s -H 'Content-Type: application/json' -d '{"batcherLabel":"testbatcher","confTarget":32}' proxy:8888/createbatcher)
|
response=$(exec_in_test_container curl -s -H 'Content-Type: application/json' -d '{"batcherLabel":"testbatcher","confTarget":32}' proxy:8888/createbatcher)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id=$(echo "${response}" | jq -e ".result.batcherId")
|
id=$(echo "${response}" | jq -e ".result.batcherId")
|
||||||
if [ "$?" -ne "0" ]; then
|
if [ "$?" -ne "0" ]; then
|
||||||
exit 70
|
exit 70
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# List batchers (should show at least default and testbatcher batchers)
|
# List batchers (should show at least default and testbatcher batchers)
|
||||||
echo "Testing listbatches..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing listbatches...${Color_Off}\n"
|
||||||
response=$(curl -s proxy:8888/listbatchers)
|
response=$(exec_in_test_container curl -s proxy:8888/listbatchers)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
id=$(echo "${response}" | jq '.result[] | select(.batcherLabel == "testbatcher") | .batcherId')
|
id=$(echo "${response}" | jq '.result[] | select(.batcherLabel == "testbatcher") | .batcherId')
|
||||||
echo "batcherId=${id}"
|
trace 3 "[testbatching] batcherId=${id}"
|
||||||
if [ -z "${id}" ]; then
|
if [ -z "${id}" ]; then
|
||||||
exit 75
|
exit 75
|
||||||
fi
|
fi
|
||||||
echo "Tested listbatchers."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested listbatchers.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatcher the testbatcher batcher
|
# getbatcher the testbatcher batcher
|
||||||
echo "Testing getbatcher..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatcher...${Color_Off}\n"
|
||||||
response=$(curl -sd '{"batcherId":'${id}'}' localhost:8888/getbatcher)
|
response=$(exec_in_test_container curl -sd '{"batcherId":'${id}'}' proxy:8888/getbatcher)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
trace 3 "[testbatching] batcherLabel=${data}"
|
||||||
if [ "${data}" != "testbatcher" ]; then
|
if [ "${data}" != "testbatcher" ]; then
|
||||||
exit 80
|
exit 80
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"batcherLabel":"testbatcher"}' localhost:8888/getbatcher)
|
response=$(exec_in_test_container curl -sd '{"batcherLabel":"testbatcher"}' proxy:8888/getbatcher)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherId")
|
data=$(echo "${response}" | jq -r ".result.batcherId")
|
||||||
echo "batcherId=${data}"
|
trace 3 "[testbatching] batcherId=${data}"
|
||||||
if [ "${data}" != "${id}" ]; then
|
if [ "${data}" != "${id}" ]; then
|
||||||
exit 90
|
exit 90
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatcher."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatcher.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatchdetails the testbatcher batcher
|
# getbatchdetails the testbatcher batcher
|
||||||
echo "Testing getbatchdetails..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatchdetails...${Color_Off}\n"
|
||||||
response=$(curl -sd '{"batcherLabel":"testbatcher"}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{"batcherLabel":"testbatcher"}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherId")
|
data=$(echo "${response}" | jq -r ".result.batcherId")
|
||||||
echo "batcherId=${data}"
|
trace 3 "[testbatching] batcherId=${data}"
|
||||||
if [ "${data}" != "${id}" ]; then
|
if [ "${data}" != "${id}" ]; then
|
||||||
exit 100
|
exit 100
|
||||||
fi
|
fi
|
||||||
@@ -258,10 +273,10 @@ testbatching() {
|
|||||||
exit 110
|
exit 110
|
||||||
fi
|
fi
|
||||||
|
|
||||||
response=$(curl -sd '{"batcherId":'${id}'}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{"batcherId":'${id}'}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||||
echo "batcherLabel=${data}"
|
trace 3 "[testbatching] batcherLabel=${data}"
|
||||||
if [ "${data}" != "testbatcher" ]; then
|
if [ "${data}" != "testbatcher" ]; then
|
||||||
exit 120
|
exit 120
|
||||||
fi
|
fi
|
||||||
@@ -269,16 +284,16 @@ testbatching() {
|
|||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 130
|
exit 130
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||||
|
|
||||||
# addtobatch to testbatcher batcher
|
# addtobatch to testbatcher batcher
|
||||||
echo "Testing addtobatch..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing addtobatch...${Color_Off}\n"
|
||||||
address1=$(curl -s localhost:8888/getnewaddress | jq -r ".address")
|
address1=$(exec_in_test_container curl -s proxy:8888/getnewaddress | jq -r ".address")
|
||||||
echo "address1=${address1}"
|
trace 3 "[testbatching] address1=${address1}"
|
||||||
response=$(curl -sd '{"batcherId":'${id}',"outputLabel":"test001","address":"'${address1}'","amount":0.001,"webhookUrl":"'${url1}'/'${address1}'"}' localhost:8888/addtobatch)
|
response=$(exec_in_test_container curl -sd '{"batcherId":'${id}',"outputLabel":"test001","address":"'${address1}'","amount":0.001,"webhookUrl":"'${url1}'/'${address1}'"}' proxy:8888/addtobatch)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq ".result.batcherId")
|
data=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${data}"
|
trace 3 "[testbatching] batcherId=${data}"
|
||||||
if [ "${data}" -ne "${id}" ]; then
|
if [ "${data}" -ne "${id}" ]; then
|
||||||
exit 140
|
exit 140
|
||||||
fi
|
fi
|
||||||
@@ -286,14 +301,14 @@ testbatching() {
|
|||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 142
|
exit 142
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id2}"
|
trace 3 "[testbatching] outputId=${id2}"
|
||||||
|
|
||||||
address2=$(curl -s localhost:8888/getnewaddress | jq -r ".address")
|
address2=$(exec_in_test_container curl -s proxy:8888/getnewaddress | jq -r ".address")
|
||||||
echo "address2=${address2}"
|
trace 3 "[testbatching] address2=${address2}"
|
||||||
response=$(curl -sd '{"batcherLabel":"testbatcher","outputLabel":"test002","address":"'${address2}'","amount":0.002,"webhookUrl":"'${url2}'/'${address2}'"}' localhost:8888/addtobatch)
|
response=$(exec_in_test_container curl -sd '{"batcherLabel":"testbatcher","outputLabel":"test002","address":"'${address2}'","amount":0.002,"webhookUrl":"'${url2}'/'${address2}'"}' proxy:8888/addtobatch)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq ".result.batcherId")
|
data=$(echo "${response}" | jq ".result.batcherId")
|
||||||
echo "batcherId=${data}"
|
trace 3 "[testbatching] batcherId=${data}"
|
||||||
if [ "${data}" -ne "${id}" ]; then
|
if [ "${data}" -ne "${id}" ]; then
|
||||||
exit 150
|
exit 150
|
||||||
fi
|
fi
|
||||||
@@ -301,35 +316,35 @@ testbatching() {
|
|||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 152
|
exit 152
|
||||||
fi
|
fi
|
||||||
echo "outputId=${id2}"
|
trace 3 "[testbatching] outputId=${id2}"
|
||||||
echo "Tested addtobatch."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested addtobatch.${Color_Off}\n"
|
||||||
|
|
||||||
# batchspend testbatcher batcher
|
# batchspend testbatcher batcher
|
||||||
echo "Testing batchspend..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing batchspend...${Color_Off}\n"
|
||||||
response=$(curl -sd '{"batcherLabel":"testbatcher"}' localhost:8888/batchspend)
|
response=$(exec_in_test_container curl -sd '{"batcherLabel":"testbatcher"}' proxy:8888/batchspend)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data2=$(echo "${response}" | jq -e ".result.txid")
|
data2=$(echo "${response}" | jq -e ".result.txid")
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
exit 160
|
exit 160
|
||||||
fi
|
fi
|
||||||
echo "txid=${data2}"
|
trace 3 "[testbatching] txid=${data2}"
|
||||||
data=$(echo "${response}" | jq ".result.outputs | length")
|
data=$(echo "${response}" | jq ".result.outputs | length")
|
||||||
if [ "${data}" -ne "2" ]; then
|
if [ "${data}" -ne "2" ]; then
|
||||||
exit 162
|
exit 162
|
||||||
fi
|
fi
|
||||||
echo "Tested batchspend."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested batchspend.${Color_Off}\n"
|
||||||
|
|
||||||
# getbatchdetails the testbatcher batcher
|
# getbatchdetails the testbatcher batcher
|
||||||
echo "Testing getbatchdetails..."
|
trace 2 "\n\n[testbatching] ${BCyan}Testing getbatchdetails...${Color_Off}\n"
|
||||||
echo "txid=${data2}"
|
trace 3 "[testbatching] txid=${data2}"
|
||||||
response=$(curl -sd '{"batcherLabel":"testbatcher","txid":'${data2}'}' localhost:8888/getbatchdetails)
|
response=$(exec_in_test_container curl -sd '{"batcherLabel":"testbatcher","txid":'${data2}'}' proxy:8888/getbatchdetails)
|
||||||
echo "response=${response}"
|
trace 3 "[testbatching] response=${response}"
|
||||||
data=$(echo "${response}" | jq ".result.nbOutputs")
|
data=$(echo "${response}" | jq ".result.nbOutputs")
|
||||||
echo "nbOutputs=${data}"
|
trace 3 "[testbatching] nbOutputs=${data}"
|
||||||
if [ "${data}" -ne "2" ]; then
|
if [ "${data}" -ne "2" ]; then
|
||||||
exit 170
|
exit 170
|
||||||
fi
|
fi
|
||||||
echo "Tested getbatchdetails."
|
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||||
|
|
||||||
# List batchers
|
# List batchers
|
||||||
# Add to batch
|
# Add to batch
|
||||||
@@ -337,16 +352,33 @@ testbatching() {
|
|||||||
# Remove from batch
|
# Remove from batch
|
||||||
# List batchers
|
# List batchers
|
||||||
|
|
||||||
echo
|
trace 1 "\n\n[testbatching] ${On_IGreen}${BBlack} ALL GOOD! Yayyyy! ${Color_Off}\n"
|
||||||
echo "Tests successful!"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_callbacks() {
|
start_callback_server() {
|
||||||
nc -vlp1111 -e sh -c 'echo -en "HTTP/1.1 200 OK\r\n\r\n" ; timeout 1 tee /dev/tty | cat ; echo 1>&2' &
|
trace 1 "\n\n[start_callback_server] ${BCyan}Let's start a callback server!...${Color_Off}\n"
|
||||||
nc -vlp1112 -e sh -c 'echo -en "HTTP/1.1 200 OK\r\n\r\n" ; timeout 1 tee /dev/tty | cat ; echo 1>&2' &
|
|
||||||
|
port=${1:-${callbackserverport}}
|
||||||
|
docker run --rm -t --name tests-batching-cb --network=cyphernodenet alpine sh -c "nc -vlp${port} -e sh -c 'echo -en \"HTTP/1.1 200 OK\\\\r\\\\n\\\\r\\\\n\" ; echo -en \"\\033[40m\\033[0;37m\" >&2 ; date >&2 ; timeout 1 tee /dev/tty | cat ; echo -e \"\033[0m\" >&2'" &
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_callbacks
|
TRACING=3
|
||||||
|
|
||||||
|
stop_test_container
|
||||||
|
start_test_container
|
||||||
|
|
||||||
|
callbackserverport="1111"
|
||||||
|
callbackservername="tests-batching-cb"
|
||||||
|
|
||||||
|
trace 1 "\n\n[test-batching] ${BCyan}Installing needed packages...${Color_Off}\n"
|
||||||
|
exec_in_test_container apk add --update curl
|
||||||
|
|
||||||
testbatching
|
testbatching
|
||||||
|
|
||||||
|
trace 1 "\n\n[test-batching] ${BCyan}Tearing down...${Color_Off}\n"
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
stop_test_container
|
||||||
|
|
||||||
|
trace 1 "\n\n[test-batching] ${BCyan}See ya!${Color_Off}\n"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# docker run -it --rm -it --name test-derive --network=cyphernodenet -v "$PWD/test-derive.sh:/test-derive.sh" alpine /test-derive.sh
|
. ./colors.sh
|
||||||
|
|
||||||
|
# You need jq installed for these tests to run correctly
|
||||||
|
|
||||||
# This will test:
|
# This will test:
|
||||||
#
|
#
|
||||||
@@ -12,7 +14,27 @@
|
|||||||
# ...and it will compare performance between Pycoin et Bitcoin Core's address derivations...
|
# ...and it will compare performance between Pycoin et Bitcoin Core's address derivations...
|
||||||
#
|
#
|
||||||
|
|
||||||
test_derive() {
|
trace() {
|
||||||
|
if [ "${1}" -le "${TRACING}" ]; then
|
||||||
|
echo "$(date -u +%FT%TZ) ${2}" 1>&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_test_container() {
|
||||||
|
docker run -d --rm -it --name test-derive --network=cyphernodenet alpine
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_test_container() {
|
||||||
|
trace 1 "\n\n[stop_test_container] ${BCyan}Stopping existing containers if they are running...${Color_Off}\n"
|
||||||
|
|
||||||
|
docker stop test-derive
|
||||||
|
}
|
||||||
|
|
||||||
|
exec_in_test_container() {
|
||||||
|
docker exec -it test-derive "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
tests_derive() {
|
||||||
local address
|
local address
|
||||||
local address1
|
local address1
|
||||||
local address2
|
local address2
|
||||||
@@ -20,14 +42,17 @@ test_derive() {
|
|||||||
local response
|
local response
|
||||||
local transaction
|
local transaction
|
||||||
|
|
||||||
|
trace 1 "\n\n[tests_derive] ${BCyan}Let's test the derivation features!...${Color_Off}\n"
|
||||||
|
|
||||||
# deriveindex
|
# deriveindex
|
||||||
# (GET) http://proxy:8888/deriveindex/25-30
|
# (GET) http://proxy:8888/deriveindex/25-30
|
||||||
# {"addresses":[{"address":"2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8"},{"address":"2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV"},{"address":"2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP"},{"address":"2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6"},{"address":"2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH"},{"address":"2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"}]}
|
# {"addresses":[{"address":"2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8"},{"address":"2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV"},{"address":"2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP"},{"address":"2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6"},{"address":"2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH"},{"address":"2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"}]}
|
||||||
|
|
||||||
echo "Testing deriveindex..."
|
trace 2 "\n\n[tests_derive] ${BCyan}Testing deriveindex...${Color_Off}\n"
|
||||||
response=$(curl -s proxy:8888/deriveindex/25-30)
|
response=$(exec_in_test_container curl -s proxy:8888/deriveindex/25-30)
|
||||||
echo "response=${response}"
|
trace 3 "[tests_derive] response=${response}"
|
||||||
local nbaddr=$(echo "${response}" | jq ".addresses | length")
|
local nbaddr=$(echo "${response}" | jq ".addresses | length")
|
||||||
|
trace 3 "[tests_derive] nbaddr=${nbaddr}"
|
||||||
if [ "${nbaddr}" -ne "6" ]; then
|
if [ "${nbaddr}" -ne "6" ]; then
|
||||||
exit 130
|
exit 130
|
||||||
fi
|
fi
|
||||||
@@ -35,16 +60,16 @@ test_derive() {
|
|||||||
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
||||||
exit 140
|
exit 140
|
||||||
fi
|
fi
|
||||||
echo "Tested deriveindex."
|
trace 2 "\n\n[tests_derive] ${BCyan}Tested deriveindex.${Color_Off}\n"
|
||||||
|
|
||||||
# derivepubpath
|
# derivepubpath
|
||||||
# (GET) http://proxy:8888/derivepubpath
|
# (GET) http://proxy:8888/derivepubpath
|
||||||
# BODY {"pub32":"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb","path":"0/25-30"}
|
# BODY {"pub32":"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb","path":"0/25-30"}
|
||||||
# {"addresses":[{"address":"2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8"},{"address":"2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV"},{"address":"2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP"},{"address":"2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6"},{"address":"2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH"},{"address":"2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"}]}
|
# {"addresses":[{"address":"2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8"},{"address":"2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV"},{"address":"2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP"},{"address":"2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6"},{"address":"2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH"},{"address":"2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"}]}
|
||||||
|
|
||||||
echo "Testing derivepubpath..."
|
trace 2 "\n\n[tests_derive] ${BCyan}Testing derivepubpath...${Color_Off}\n"
|
||||||
response=$(curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/25-30\"}" proxy:8888/derivepubpath)
|
response=$(exec_in_test_container curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/25-30\"}" proxy:8888/derivepubpath)
|
||||||
echo "response=${response}"
|
trace 3 "[tests_derive] response=${response}"
|
||||||
local nbaddr=$(echo "${response}" | jq ".addresses | length")
|
local nbaddr=$(echo "${response}" | jq ".addresses | length")
|
||||||
if [ "${nbaddr}" -ne "6" ]; then
|
if [ "${nbaddr}" -ne "6" ]; then
|
||||||
exit 150
|
exit 150
|
||||||
@@ -53,15 +78,15 @@ test_derive() {
|
|||||||
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
||||||
exit 160
|
exit 160
|
||||||
fi
|
fi
|
||||||
echo "Tested derivepubpath."
|
trace 2 "\n\n[tests_derive] ${BCyan}Tested derivepubpath.${Color_Off}\n"
|
||||||
|
|
||||||
# deriveindex_bitcoind
|
# deriveindex_bitcoind
|
||||||
# (GET) http://proxy:8888/deriveindex_bitcoind/25-30
|
# (GET) http://proxy:8888/deriveindex_bitcoind/25-30
|
||||||
# ["2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8","2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV","2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP","2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6","2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH","2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"]
|
# ["2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8","2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV","2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP","2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6","2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH","2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"]
|
||||||
|
|
||||||
echo "Testing deriveindex_bitcoind..."
|
trace 2 "\n\n[tests_derive] ${BCyan}Testing deriveindex_bitcoind...${Color_Off}\n"
|
||||||
response=$(curl -s proxy:8888/deriveindex_bitcoind/25-30)
|
response=$(exec_in_test_container curl -s proxy:8888/deriveindex_bitcoind/25-30)
|
||||||
echo "response=${response}"
|
trace 3 "[tests_derive] response=${response}"
|
||||||
local nbaddr=$(echo "${response}" | jq ". | length")
|
local nbaddr=$(echo "${response}" | jq ". | length")
|
||||||
if [ "${nbaddr}" -ne "6" ]; then
|
if [ "${nbaddr}" -ne "6" ]; then
|
||||||
exit 130
|
exit 130
|
||||||
@@ -70,16 +95,16 @@ test_derive() {
|
|||||||
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
||||||
exit 140
|
exit 140
|
||||||
fi
|
fi
|
||||||
echo "Tested deriveindex_bitcoind."
|
trace 2 "\n\n[tests_derive] ${BCyan}Tested deriveindex_bitcoind.${Color_Off}\n"
|
||||||
|
|
||||||
# derivepubpath_bitcoind
|
# derivepubpath_bitcoind
|
||||||
# (GET) http://proxy:8888/derivepubpath_bitcoind
|
# (GET) http://proxy:8888/derivepubpath_bitcoind
|
||||||
# BODY {"pub32":"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb","path":"0/25-30"}
|
# BODY {"pub32":"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb","path":"0/25-30"}
|
||||||
# ["2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8","2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV","2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP","2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6","2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH","2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"]
|
# ["2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8","2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV","2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP","2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6","2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH","2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw"]
|
||||||
|
|
||||||
echo "Testing derivepubpath_bitcoind..."
|
trace 2 "\n\n[tests_derive] ${BCyan}Testing derivepubpath_bitcoind...${Color_Off}\n"
|
||||||
response=$(curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/25-30\"}" proxy:8888/derivepubpath_bitcoind)
|
response=$(exec_in_test_container curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/25-30\"}" proxy:8888/derivepubpath_bitcoind)
|
||||||
echo "response=${response}"
|
trace 3 "[tests_derive] response=${response}"
|
||||||
local nbaddr=$(echo "${response}" | jq ". | length")
|
local nbaddr=$(echo "${response}" | jq ". | length")
|
||||||
if [ "${nbaddr}" -ne "6" ]; then
|
if [ "${nbaddr}" -ne "6" ]; then
|
||||||
exit 150
|
exit 150
|
||||||
@@ -88,14 +113,14 @@ test_derive() {
|
|||||||
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
if [ "${address}" != "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP" ]; then
|
||||||
exit 160
|
exit 160
|
||||||
fi
|
fi
|
||||||
echo "Tested derivepubpath_bitcoind."
|
trace 2 "\n\n[tests_derive] ${BCyan}Tested derivepubpath_bitcoind.${Color_Off}\n"
|
||||||
|
|
||||||
# deriveindex_bitcoind and derivepubpath_bitcoind faster derivation?
|
# deriveindex_bitcoind and derivepubpath_bitcoind faster derivation?
|
||||||
echo -e "\nDeriving 500 addresses with derivepubpath (Pycoin)..."
|
trace 2 "\n\n[tests_derive] ${BCyan}Deriving 500 addresses with derivepubpath (Pycoin)...${Color_Off}\n"
|
||||||
time curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/0-499\"}" proxy:8888/derivepubpath > /dev/null
|
exec_in_test_container sh -c 'time curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/0-499\"}" proxy:8888/derivepubpath > /dev/null'
|
||||||
|
|
||||||
echo -e "\nDeriving 500 addresses with derivepubpath_bitcoind (Bitcoin Core)..."
|
trace 2 "\n\n[tests_derive] ${BCyan}Deriving 500 addresses with derivepubpath_bitcoind (Bitcoin Core)...${Color_Off}\n"
|
||||||
time curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/0-499\"}" proxy:8888/derivepubpath_bitcoind > /dev/null
|
exec_in_test_container sh -c 'time curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/0-499\"}" proxy:8888/derivepubpath_bitcoind > /dev/null'
|
||||||
|
|
||||||
# Deriving 500 addresses with derivepubpath (pycoin)...
|
# Deriving 500 addresses with derivepubpath (pycoin)...
|
||||||
# real 0m 18.15s
|
# real 0m 18.15s
|
||||||
@@ -107,8 +132,23 @@ test_derive() {
|
|||||||
# user 0m 0.00s
|
# user 0m 0.00s
|
||||||
# sys 0m 0.00s
|
# sys 0m 0.00s
|
||||||
|
|
||||||
|
trace 1 "\n\n[tests_derive] ${On_IGreen}${BBlack} ALL GOOD! Yayyyy! ${Color_Off}\n"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apk add curl jq
|
TRACING=3
|
||||||
|
|
||||||
test_derive
|
stop_test_container
|
||||||
|
start_test_container
|
||||||
|
|
||||||
|
trace 1 "\n\n[test-derive] ${BCyan}Installing needed packages...${Color_Off}\n"
|
||||||
|
exec_in_test_container apk add --update curl
|
||||||
|
|
||||||
|
tests_derive
|
||||||
|
|
||||||
|
trace 1 "\n\n[test-derive] ${BCyan}Tearing down...${Color_Off}\n"
|
||||||
|
wait
|
||||||
|
|
||||||
|
stop_test_container
|
||||||
|
|
||||||
|
trace 1 "\n\n[test-derive] ${BCyan}See ya!${Color_Off}\n"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
. ./mine.sh
|
. ./mine.sh
|
||||||
|
|
||||||
# This needs to be run in regtest
|
# This needs to be run in regtest
|
||||||
|
# You need jq installed for these tests to run correctly
|
||||||
|
|
||||||
# This will test the missed watched transactions mechanisms by broadcasting
|
# This will test the missed watched transactions mechanisms by broadcasting
|
||||||
# transactions on watched addresses while the proxy is shut down...
|
# transactions on watched addresses while the proxy is shut down...
|
||||||
@@ -141,7 +142,7 @@ trace 2 "url2=${url2}"
|
|||||||
trace 2 "url3=${url3}"
|
trace 2 "url3=${url3}"
|
||||||
trace 2 "url4=${url4}"
|
trace 2 "url4=${url4}"
|
||||||
|
|
||||||
exec_in_test_container apk add curl
|
exec_in_test_container apk add --update curl
|
||||||
# exec_in_test_container ping -c 5 tests-manage-missed
|
# exec_in_test_container ping -c 5 tests-manage-missed
|
||||||
# exec_in_test_container curl -vd 'toto' ${url1}/allo
|
# exec_in_test_container curl -vd 'toto' ${url1}/allo
|
||||||
test_manage_missed_0_conf
|
test_manage_missed_0_conf
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
. ./mine.sh
|
. ./mine.sh
|
||||||
|
|
||||||
# This needs to be run in regtest
|
# This needs to be run in regtest
|
||||||
|
# You need jq installed for these tests to run correctly
|
||||||
|
|
||||||
# This will test:
|
# This will test:
|
||||||
#
|
#
|
||||||
@@ -30,7 +31,7 @@ start_test_container() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop_test_container() {
|
stop_test_container() {
|
||||||
trace 1 "\n\n[test_watch_pub32] ${BCyan}Stopping existing containers if they are running...${Color_Off}\n"
|
trace 1 "\n\n[stop_test_container] ${BCyan}Stopping existing containers if they are running...${Color_Off}\n"
|
||||||
|
|
||||||
docker stop tests-watch-pub32
|
docker stop tests-watch-pub32
|
||||||
docker stop tests-watch-pub32-cb
|
docker stop tests-watch-pub32-cb
|
||||||
@@ -433,7 +434,7 @@ callbackserverport="1111"
|
|||||||
callbackservername="tests-watch-pub32-cb"
|
callbackservername="tests-watch-pub32-cb"
|
||||||
|
|
||||||
trace 1 "\n\n[test_watch_pub32] ${BCyan}Installing needed packages...${Color_Off}\n"
|
trace 1 "\n\n[test_watch_pub32] ${BCyan}Installing needed packages...${Color_Off}\n"
|
||||||
exec_in_test_container apk add curl
|
exec_in_test_container apk add --update curl
|
||||||
|
|
||||||
test_watch_pub32
|
test_watch_pub32
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user