From: alex Date: Sun, 26 Jun 2022 07:55:57 +0000 (-0700) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=b5801682bc276cd7a4b9ce59c6674573d2404035;p=cold ... --- diff --git a/cold-setup b/cold-setup index a256a5a..62afaf9 100755 --- a/cold-setup +++ b/cold-setup @@ -113,7 +113,7 @@ multisig_create() { echo -n '{"desc": "' >> "$DUMPFILE" eval "$CMD" >> "$DUMPFILE" - echo -n '", "active": true, "timestamp": "now"}]' >> "$DUMPFILE" + echo -n '", "active": true, "timestamp": "now", "internal": true}]' >> "$DUMPFILE" } network_off() { @@ -215,7 +215,6 @@ usb_crypt_close() { usb_detect() { local DEVNAME - log_msg "plug in usb drive now.\ndetecting..." coproc udevadm monitor -s block/disk -u -p @@ -236,7 +235,6 @@ usb_detect() { kill $COPROC_PID - log_msg "found usb drive: $DEVNAME" echo "$DEVNAME" } diff --git a/test/setup.sh b/test/setup.sh index adbda6e..36c6bfd 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -4,6 +4,14 @@ TEST_DIR=".testdir" source source.sh +assert() { + if [[ "$1" != "$2" ]]; then + echo -e "Expected:\n$1\nResult:\n$2" + echo -e "${BASH_SOURCE[1]}:${BASH_LINENO[0]} \e[31mFAILED\e[0m" + exit 1 + fi +} + clean_env() { bitcoin_core_stop cd .. @@ -16,7 +24,7 @@ setup_env() { bitcoin_core_start } > /dev/null 2>&1 -setup_test_wallets() { +setup_test_descriptors() { cat > wallet1.descriptors << EOF { "wallet_name": "wallet1", @@ -688,6 +696,10 @@ EOF ] } EOF +} + +setup_test_wallets() { + setup_test_descriptors for((i = 1; i<= 7; i++)); do (wallet_load "$i" "wallet$i.descriptors" > result 2>&1) @@ -729,14 +741,6 @@ reset_env() { setup_env } -assert() { - if [[ "$1" != "$2" ]]; then - echo -e "Expected:\n$1\nResult:\n$2" - echo -e "${BASH_SOURCE[1]}:${BASH_LINENO[0]} \e[31mFAILED\e[0m" - exit 1 - fi -} - test_failed() { echo -e "${BASH_SOURCE[1]}:${BASH_LINENO[0]} \e[31mFAILED\e[0m" exit 1 diff --git a/test/usb_detect.tests.sh b/test/usb_detect.tests.sh index 252e259..30abada 100755 --- a/test/usb_detect.tests.sh +++ b/test/usb_detect.tests.sh @@ -7,7 +7,90 @@ source setup.sh mkdir "$TEST_DIR" cd "$TEST_DIR" -test_failed +udevadm() { + # remove event for /dev/sdf + echo "UDEV [1787.032378] remove /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host8/target8:0:0/8:0:0:0/block/sdf (block) +ACTION=remove +DEVPATH=/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host8/target8:0:0/8:0:0:0/block/sdf +SUBSYSTEM=block +DEVNAME=/dev/sdf +DEVTYPE=disk +SEQNUM=3185 +USEC_INITIALIZED=1778132471 +ID_VENDOR=Flash +ID_VENDOR_ENC=Flash\x20\x20\x20 +ID_VENDOR_ID=1221 +ID_MODEL=USB_Disk +ID_MODEL_ENC=USB\x20Disk\x20\x20\x20\x20\x20\x20\x20\x20 +ID_MODEL_ID=3234 +ID_REVISION=2.F0 +ID_SERIAL=Flash_USB_Disk_37270108153C451042955-0:0 +ID_SERIAL_SHORT=37270108153C451042955 +ID_TYPE=disk +ID_INSTANCE=0:0 +ID_BUS=usb +ID_USB_INTERFACES=:080650: +ID_USB_INTERFACE_NUM=00 +ID_USB_DRIVER=usb-storage +ID_PATH=pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0 +ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_0-scsi-0_0_0_0 +ID_PART_TABLE_UUID=00203954 +ID_PART_TABLE_TYPE=dos +.ID_FS_TYPE_NEW= +ID_FS_TYPE= +MAJOR=8 +MINOR=80 +DEVLINKS=/dev/disk/by-id/usb-Flash_USB_Disk_37270108153C451042955-0:0 /dev/disk/by-path/pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0 +TAGS=:systemd: +CURRENT_TAGS=:systemd: +" + # add event for /dev/sdz + echo "monitor will print the received events for: +UDEV - the event which udev sends out after rule processing + +UDEV [1778.138888] add /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host8/target8:0:0/8:0:0:0/block/sdz (block) +ACTION=add +DEVPATH=/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host8/target8:0:0/8:0:0:0/block/sdf +SUBSYSTEM=block +DEVNAME=/dev/sdz +DEVTYPE=disk +SEQNUM=3176 +USEC_INITIALIZED=1778132471 +ID_VENDOR=Flash +ID_VENDOR_ENC=Flash\x20\x20\x20 +ID_VENDOR_ID=1221 +ID_MODEL=USB_Disk +ID_MODEL_ENC=USB\x20Disk\x20\x20\x20\x20\x20\x20\x20\x20 +ID_MODEL_ID=3234 +ID_REVISION=2.F0 +ID_SERIAL=Flash_USB_Disk_37270108153C451042955-0:0 +ID_SERIAL_SHORT=37270108153C451042955 +ID_TYPE=disk +ID_INSTANCE=0:0 +ID_BUS=usb +ID_USB_INTERFACES=:080650: +ID_USB_INTERFACE_NUM=00 +ID_USB_DRIVER=usb-storage +ID_PATH=pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0 +ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_0-scsi-0_0_0_0 +ID_PART_TABLE_UUID=00203954 +ID_PART_TABLE_TYPE=dos +.ID_FS_TYPE_NEW= +ID_FS_TYPE= +MAJOR=8 +MINOR=80 +DEVLINKS=/dev/disk/by-id/usb-Flash_USB_Disk_37270108153C451042955-0:0 /dev/disk/by-path/pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0 +TAGS=:systemd: +CURRENT_TAGS=:systemd: +" + while true; do + echo "here" > /dev/null + done +} + +(usb_detect > result) +EXPECTED="/dev/sdz" +assert "$EXPECTED" "$( result) +EXPECTED='{ + "name": "wallet8", + "warning": "" +}' +assert "$EXPECTED" "$( result) +EXPECTED='[ + { + "success": true, + "warnings": [ + "Range not given, using default keypool range" + ] + }, + { + "success": true, + "warnings": [ + "Range not given, using default keypool range" + ] + } +]' +assert "$EXPECTED" "$( result) +EXPECTED='{ + "walletname": "wallet8", + "walletversion": 169900, + "format": "sqlite", + "balance": 0.00000000, + "unconfirmed_balance": 0.00000000, + "immature_balance": 0.00000000, + "txcount": 0, + "keypoolsize": 1000, + "keypoolsize_hd_internal": 1000, + "paytxfee": 0.00000000, + "private_keys_enabled": false, + "avoid_reuse": false, + "scanning": false, + "descriptors": true, + "external_signer": false +}' +assert "$EXPECTED" "$(> addresses +done + +assert "b9890d9705e771dc84061e4b119bb21c87d200fac02957d2e3f71be4fc6694111dc56e8a259bc1151b3bf7bb3d77e6239f1ecd606fd1f798ad5c915968e2d20f addresses" "`b2sum addresses`" + +clean_env + +test_succeeded diff --git a/test/wallet_multisig_spend_correctness.tests.sh b/test/wallet_multisig_spend_correctness.tests.sh new file mode 100755 index 0000000..8eb67c8 --- /dev/null +++ b/test/wallet_multisig_spend_correctness.tests.sh @@ -0,0 +1,226 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source setup.sh + +setup_env + +setup_test_wallets + +multisig_create + +delete_wallet() { + eval "$BITCOIN_CLI unloadwallet wallet$1" > /dev/null + rm -rf "$DATA_DIRECTORY/regtest/wallets/wallet$1" +} + +load() { + (wallet_load "$1" "wallet$1.descriptors" > result 2>&1) + EXPECTED="created blank wallet: wallet$1 +[ + { + \"success\": true + }, + { + \"success\": true + }, + { + \"success\": true + }, + { + \"success\": true + }, + { + \"success\": true + }, + { + \"success\": true + }, + { + \"success\": true + }, + { + \"success\": true + } +] +loaded descriptors for wallet$1 from wallet$1.descriptors" + RESULT=$( /dev/null +} + +assert "c7f64e597a1a36e00eacd8683dd235cb5a27718b93020a450ef8dfaadcadc971944cf9ecb222523f45aab629e07d0b30432811ebcec1a93f7c9185feadf7d722 $DATA_DIRECTORY/descriptors.txt" "`b2sum $DATA_DIRECTORY/descriptors.txt`" +MULTISIG_DESCRIPTORS="`cat "$DATA_DIRECTORY/descriptors.txt"`" + +reset_env + +setup_test_descriptors + +(eval "$BITCOIN_CLI -named createwallet wallet_name=live descriptors=true blank=true disable_private_keys=true" > result) +EXPECTED='{ + "name": "live", + "warning": "" +}' +assert "$EXPECTED" "$( result) +EXPECTED='{ + "name": "dummy", + "warning": "" +}' +assert "$EXPECTED" "$( result) +EXPECTED='[ + { + "success": true, + "warnings": [ + "Range not given, using default keypool range" + ] + }, + { + "success": true, + "warnings": [ + "Range not given, using default keypool range" + ] + } +]' +assert "$EXPECTED" "$( result) +EXPECTED='{ + "walletname": "live", + "walletversion": 169900, + "format": "sqlite", + "balance": 0.00000000, + "unconfirmed_balance": 0.00000000, + "immature_balance": 0.00000000, + "txcount": 0, + "keypoolsize": 1000, + "keypoolsize_hd_internal": 1000, + "paytxfee": 0.00000000, + "private_keys_enabled": false, + "avoid_reuse": false, + "scanning": false, + "descriptors": true, + "external_signer": false +}' +assert "$EXPECTED" "$( /dev/null +eval "$BITCOIN_CLI -rpcwallet=dummy -generate 100" > /dev/null + +(eval "$BITCOIN_CLI -rpcwallet=dummy getwalletinfo | jq .balance" > result) +assert "5000" "$( /dev/null +done + +eval "$BITCOIN_CLI -rpcwallet=dummy -generate 100" > /dev/null + +(eval "$BITCOIN_CLI -rpcwallet=live getwalletinfo" > result) +EXPECTED='{ + "walletname": "live", + "walletversion": 169900, + "format": "sqlite", + "balance": 1000.00000000, + "unconfirmed_balance": 0.00000000, + "immature_balance": 0.00000000, + "txcount": 1000, + "keypoolsize": 1000, + "keypoolsize_hd_internal": 1000, + "paytxfee": 0.00000000, + "private_keys_enabled": false, + "avoid_reuse": false, + "scanning": false, + "descriptors": true, + "external_signer": false +}' +assert "$EXPECTED" "$( /dev/null + +(eval "$BITCOIN_CLI -rpcwallet=live getwalletinfo" > result) +EXPECTED='{ + "walletname": "live", + "walletversion": 169900, + "format": "sqlite", + "balance": 499.99758000, + "unconfirmed_balance": 0.00000000, + "immature_balance": 0.00000000, + "txcount": 2000, + "keypoolsize": 1000, + "keypoolsize_hd_internal": 1000, + "paytxfee": 0.00000000, + "private_keys_enabled": false, + "avoid_reuse": false, + "scanning": false, + "descriptors": true, + "external_signer": false +}' +assert "$EXPECTED" "$( /dev/null + +(eval "$BITCOIN_CLI -rpcwallet=live getwalletinfo" > result) +EXPECTED='{ + "walletname": "live", + "walletversion": 169900, + "format": "sqlite", + "balance": 0.00000000, + "unconfirmed_balance": 0.00000000, + "immature_balance": 0.00000000, + "txcount": 2005, + "keypoolsize": 1000, + "keypoolsize_hd_internal": 1000, + "paytxfee": 0.00000000, + "private_keys_enabled": false, + "avoid_reuse": false, + "scanning": false, + "descriptors": true, + "external_signer": false +}' +assert "$EXPECTED" "$(