Fixed labels in watches and added tests

This commit is contained in:
kexkey
2021-09-06 15:08:10 -04:00
parent d7cc865cad
commit 8268247c83
5 changed files with 13 additions and 10 deletions

View File

@@ -29,6 +29,7 @@ CREATE TABLE watching (
); );
CREATE INDEX idx_watching_address ON watching (address); CREATE INDEX idx_watching_address ON watching (address);
CREATE UNIQUE INDEX idx_watching_01 ON watching (address, callback0conf, callback1conf); CREATE UNIQUE INDEX idx_watching_01 ON watching (address, callback0conf, callback1conf);
CREATE INDEX idx_watching_label ON watching (label);
CREATE TABLE watching_tx ( CREATE TABLE watching_tx (
watching_id INTEGER REFERENCES watching, watching_id INTEGER REFERENCES watching,

View File

@@ -3,6 +3,7 @@ PRAGMA foreign_keys=off;
BEGIN TRANSACTION; BEGIN TRANSACTION;
ALTER TABLE watching ADD COLUMN label TEXT; ALTER TABLE watching ADD COLUMN label TEXT;
CREATE INDEX idx_watching_label ON watching (label);
COMMIT; COMMIT;

View File

@@ -332,9 +332,9 @@ main() {
# #
# or... # or...
# POST http://192.168.111.152:8080/getnewaddress # POST http://192.168.111.152:8080/getnewaddress
# BODY {"address_type":"bech32","label":"myLabel"} # BODY {"addressType":"bech32","label":"myLabel"}
# BODY {"label":"myLabel"} # BODY {"label":"myLabel"}
# BODY {"address_type":"p2sh-segwit"} # BODY {"addressType":"p2sh-segwit"}
# BODY {} # BODY {}
# Let's make it work even for a GET request (equivalent to a POST with empty json object body) # Let's make it work even for a GET request (equivalent to a POST with empty json object body)

View File

@@ -275,19 +275,20 @@ getnewaddress() {
local response local response
local jqop local jqop
local addedfields local addedfieldstoresponse
local data='{"method":"getnewaddress"}' local data='{"method":"getnewaddress"}'
if [ -n "${address_type}" ] || [ -n "${label}" ]; then if [ -n "${address_type}" ] || [ -n "${label}" ]; then
jqop='. += {"params":{}}' jqop='. += {"params":{}}'
if [ -n "${label}" ]; then if [ -n "${label}" ]; then
jqop=${jqop}' | .params += {"label":"'${label}'"}' jqop=${jqop}' | .params += {"label":"'${label}'"}'
addedfields=' | . += {"label":"'${label}'"}' addedfieldstoresponse=' | . += {"label":"'${label}'"}'
fi fi
if [ -n "${address_type}" ]; then if [ -n "${address_type}" ]; then
jqop=${jqop}' | .params += {"address_type":"'${address_type}'"}' jqop=${jqop}' | .params += {"addressType":"'${address_type}'"}'
addedfields=' | . += {"address_type":"'${address_type}'"}' addedfieldstoresponse=' | . += {"addressType":"'${address_type}'"}'
fi fi
trace "[getnewaddress] jqop=${jqop}" trace "[getnewaddress] jqop=${jqop}"
trace "[getnewaddress] addedfieldstoresponse=${addedfieldstoresponse}"
data=$(echo "${data}" | jq -rc "${jqop}") data=$(echo "${data}" | jq -rc "${jqop}")
fi fi
@@ -304,7 +305,7 @@ getnewaddress() {
data='{"address":'${address}'}' data='{"address":'${address}'}'
if [ -n "${jqop}" ]; then if [ -n "${jqop}" ]; then
data=$(echo "${data}" | jq -rc "${data}${addedfields}") data=$(echo "${data}" | jq -rc ".${addedfieldstoresponse}")
trace "[getnewaddress] data=${data}" trace "[getnewaddress] data=${data}"
fi fi
else else

View File

@@ -10,7 +10,7 @@ trace() {
} }
start_test_container() { 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() { stop_test_container() {
@@ -55,7 +55,7 @@ test_manage_missed_0_conf() {
sleep 10 sleep 10
trace 3 "[test_manage_missed_0_conf] Calling executecallbacks..." 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 sleep 10
trace 3 "[test_manage_missed_1_conf] Calling executecallbacks..." 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() { wait_for_callbacks() {