From 8268247c836c062adf7f53d7b1c9567cd8c8d626 Mon Sep 17 00:00:00 2001 From: kexkey Date: Mon, 6 Sep 2021 15:08:10 -0400 Subject: [PATCH] Fixed labels in watches and added tests --- proxy_docker/app/data/cyphernode.sql | 1 + .../app/data/sqlmigrate20210808_0.7.0-0.8.0.sql | 1 + proxy_docker/app/script/requesthandler.sh | 4 ++-- proxy_docker/app/script/walletoperations.sh | 11 ++++++----- proxy_docker/app/tests/test-manage-missed.sh | 6 +++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/proxy_docker/app/data/cyphernode.sql b/proxy_docker/app/data/cyphernode.sql index 31e3693..17a18d6 100644 --- a/proxy_docker/app/data/cyphernode.sql +++ b/proxy_docker/app/data/cyphernode.sql @@ -29,6 +29,7 @@ CREATE TABLE watching ( ); CREATE INDEX idx_watching_address ON watching (address); CREATE UNIQUE INDEX idx_watching_01 ON watching (address, callback0conf, callback1conf); +CREATE INDEX idx_watching_label ON watching (label); CREATE TABLE watching_tx ( watching_id INTEGER REFERENCES watching, diff --git a/proxy_docker/app/data/sqlmigrate20210808_0.7.0-0.8.0.sql b/proxy_docker/app/data/sqlmigrate20210808_0.7.0-0.8.0.sql index 61ba781..1b3e557 100644 --- a/proxy_docker/app/data/sqlmigrate20210808_0.7.0-0.8.0.sql +++ b/proxy_docker/app/data/sqlmigrate20210808_0.7.0-0.8.0.sql @@ -3,6 +3,7 @@ PRAGMA foreign_keys=off; BEGIN TRANSACTION; ALTER TABLE watching ADD COLUMN label TEXT; +CREATE INDEX idx_watching_label ON watching (label); COMMIT; diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index 2ca8837..a0ad5e2 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -332,9 +332,9 @@ main() { # # or... # POST http://192.168.111.152:8080/getnewaddress - # BODY {"address_type":"bech32","label":"myLabel"} + # BODY {"addressType":"bech32","label":"myLabel"} # BODY {"label":"myLabel"} - # BODY {"address_type":"p2sh-segwit"} + # BODY {"addressType":"p2sh-segwit"} # BODY {} # Let's make it work even for a GET request (equivalent to a POST with empty json object body) diff --git a/proxy_docker/app/script/walletoperations.sh b/proxy_docker/app/script/walletoperations.sh index 4165c7a..d5c65b0 100644 --- a/proxy_docker/app/script/walletoperations.sh +++ b/proxy_docker/app/script/walletoperations.sh @@ -275,19 +275,20 @@ getnewaddress() { local response local jqop - local addedfields + local addedfieldstoresponse local data='{"method":"getnewaddress"}' if [ -n "${address_type}" ] || [ -n "${label}" ]; then jqop='. += {"params":{}}' if [ -n "${label}" ]; then jqop=${jqop}' | .params += {"label":"'${label}'"}' - addedfields=' | . += {"label":"'${label}'"}' + addedfieldstoresponse=' | . += {"label":"'${label}'"}' fi if [ -n "${address_type}" ]; then - jqop=${jqop}' | .params += {"address_type":"'${address_type}'"}' - addedfields=' | . += {"address_type":"'${address_type}'"}' + jqop=${jqop}' | .params += {"addressType":"'${address_type}'"}' + addedfieldstoresponse=' | . += {"addressType":"'${address_type}'"}' fi trace "[getnewaddress] jqop=${jqop}" + trace "[getnewaddress] addedfieldstoresponse=${addedfieldstoresponse}" data=$(echo "${data}" | jq -rc "${jqop}") fi @@ -304,7 +305,7 @@ getnewaddress() { data='{"address":'${address}'}' if [ -n "${jqop}" ]; then - data=$(echo "${data}" | jq -rc "${data}${addedfields}") + data=$(echo "${data}" | jq -rc ".${addedfieldstoresponse}") trace "[getnewaddress] data=${data}" fi else diff --git a/proxy_docker/app/tests/test-manage-missed.sh b/proxy_docker/app/tests/test-manage-missed.sh index 172db1c..e3d8e98 100755 --- a/proxy_docker/app/tests/test-manage-missed.sh +++ b/proxy_docker/app/tests/test-manage-missed.sh @@ -10,7 +10,7 @@ trace() { } start_test_container() { - docker run -d --rm -it --name tests-manage-missed --network=cyphernodenet -v "$PWD/tests-cb.sh:/tests-cb.sh" alpine + docker run -d --rm -it --name tests-manage-missed --network=cyphernodenet alpine } stop_test_container() { @@ -55,7 +55,7 @@ test_manage_missed_0_conf() { sleep 10 trace 3 "[test_manage_missed_0_conf] Calling executecallbacks..." - exec_in_test_container curl proxy:8888/executecallbacks + exec_in_test_container curl -s -H "Content-Type: application/json" proxy:8888/executecallbacks } @@ -101,7 +101,7 @@ test_manage_missed_1_conf() { sleep 10 trace 3 "[test_manage_missed_1_conf] Calling executecallbacks..." - exec_in_test_container curl proxy:8888/executecallbacks + exec_in_test_container curl -s -H "Content-Type: application/json" proxy:8888/executecallbacks } wait_for_callbacks() {