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)"
cd ..
rm -rf "$TEST_DIR"
--- /dev/null
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+source setup.sh
+
+setup_env
+
+setup_test_wallets
+
+multisig_create
+
+assert "c7f64e597a1a36e00eacd8683dd235cb5a27718b93020a450ef8dfaadcadc971944cf9ecb222523f45aab629e07d0b30432811ebcec1a93f7c9185feadf7d722 $DATA_DIRECTORY/descriptors.txt" "`b2sum $DATA_DIRECTORY/descriptors.txt`"
+
+(eval "$BITCOIN_CLI -named createwallet wallet_name=wallet8 descriptors=true blank=true disable_private_keys=true" > result)
+EXPECTED='{
+ "name": "wallet8",
+ "warning": ""
+}'
+assert "$EXPECTED" "$(<result)"
+
+(cat "$DATA_DIRECTORY/descriptors.txt" | eval "$BITCOIN_CLI -stdin -rpcwallet=wallet8 importdescriptors" > 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)"
+
+(eval "$BITCOIN_CLI -rpcwallet=wallet8 getwalletinfo" > 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" "$(<result)"
+
+
+for((i = 1; i<=1000; i++)); do
+ echo "`$BITCOIN_CLI -rpcwallet=wallet8 getnewaddress`" >> addresses
+done
+
+assert "b9890d9705e771dc84061e4b119bb21c87d200fac02957d2e3f71be4fc6694111dc56e8a259bc1151b3bf7bb3d77e6239f1ecd606fd1f798ad5c915968e2d20f addresses" "`b2sum addresses`"
+
+clean_env
+
+test_succeeded
--- /dev/null
+#!/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=$(<result)
+ assert "$EXPECTED" "$RESULT"
+}
+
+sign() {
+ local CMD="$BITCOIN_CLI -rpcwallet=wallet$2 -stdin walletprocesspsbt"
+ local SIGNED="`echo "$1" | eval "$CMD" | jq -r '.psbt'`"
+ echo "$SIGNED"
+}
+
+spend() {
+ local CMD="$BITCOIN_CLI -rpcwallet=live walletcreatefundedpsbt '[]' '[{\"$1\":$2}]'"
+ local UNSIGNED="`eval "$CMD" | jq -r '.psbt'`"
+ local WALLETS=($(shuf -n "$M" -e {1..7}))
+ for i in "${WALLETS[@]}"; do
+ load "$i"
+ UNSIGNED="`sign "$UNSIGNED" $i`"
+ delete_wallet "$i"
+ done
+
+ local FINALIZED="`echo "$UNSIGNED" | eval "$BITCOIN_CLI -stdin finalizepsbt"`"
+
+ assert "true" "`echo "$FINALIZED" | jq '.complete'`"
+
+ echo "$FINALIZED" | jq -r '.hex' | eval "$BITCOIN_CLI -stdin sendrawtransaction" > /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)"
+
+(eval "$BITCOIN_CLI -named createwallet wallet_name=dummy descriptors=true" > result)
+EXPECTED='{
+ "name": "dummy",
+ "warning": ""
+}'
+assert "$EXPECTED" "$(<result)"
+
+(echo "$MULTISIG_DESCRIPTORS" | eval "$BITCOIN_CLI -stdin -rpcwallet=live importdescriptors" > 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)"
+
+(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": 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" "$(<result)"
+
+eval "$BITCOIN_CLI -rpcwallet=dummy -generate 100" > /dev/null
+eval "$BITCOIN_CLI -rpcwallet=dummy -generate 100" > /dev/null
+
+(eval "$BITCOIN_CLI -rpcwallet=dummy getwalletinfo | jq .balance" > result)
+assert "5000" "$(<result)"
+
+for((i = 1; i<=1000; i++)); do
+ ADDRESS="`$BITCOIN_CLI -rpcwallet=live getnewaddress`"
+ eval "$BITCOIN_CLI -rpcwallet=dummy -named send outputs='{\"$ADDRESS\":1}' fee_rate=1" > /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" "$(<result)"
+
+ADDRESS="`$BITCOIN_CLI -rpcwallet=dummy getnewaddress`"
+for((j = 1; j<=1000; j++)); do
+ spend "$ADDRESS" 0.5
+ echo "$j transactions done..."
+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": 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" "$(<result)"
+
+ADDRESS="`$BITCOIN_CLI -rpcwallet=dummy getnewaddress`"
+
+spend "$ADDRESS" 100
+spend "$ADDRESS" 100
+spend "$ADDRESS" 100
+spend "$ADDRESS" 100
+spend "$ADDRESS" 99.99758
+
+eval "$BITCOIN_CLI -rpcwallet=dummy -generate 100" > /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" "$(<result)"
+
+clean_env
+
+test_succeeded