mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 21:25:06 +01:00
Fixed labels in watches and added tests
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user