What changed, and why it matters
This commit only changes the project's internal regression test script. It adds 30-second timeouts to helper functions that wait for certain conditions during automated testing, so that tests don't hang forever on the continuous integration (CI) system. There is no change to the actual Electrum wallet software that users run, and no security issue is introduced or fixed.
No security action needed. This is a routine CI/test reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies tests/regtest/regtest.sh, adding a 30-second timeout and elapsed-time counter to six wait_* helper functions used in regtest CI. Previously these loops could run indefinitely if the expected condition never occurred. The new behavior exits with status 1 after 30 seconds. The change is purely in test infrastructure and does not touch production wallet, networking, or cryptographic code.
Changed components
tests/regtest/regtest.shInspect captured patch +54 / −0
diff --git a/tests/regtest/regtest.sh b/tests/regtest/regtest.sh
index c2c8301..af3dc8d 100755
--- a/tests/regtest/regtest.sh
+++ b/tests/regtest/regtest.sh
@@ -22,8 +22,17 @@ function wait_until_htlcs_settled()
{
msg="wait until $1's local_unsettled_sent is zero"
cmd="./run_electrum --regtest -D /tmp/$1"
+ declare -i timeout_sec=30
+ declare -i elapsed_sec=0
+
while unsettled=$($cmd list_channels | jq '.[] | .local_unsettled_sent') && [ $unsettled != "0" ]; do
+ if ((elapsed_sec > timeout_sec)); then
+ printf "Timeout of %i s exceeded\n" "$elapsed_sec"
+ exit 1
+ fi
+
sleep 1
+ elapsed_sec=$((elapsed_sec + 1))
msg="$msg."
printf "$msg\r"
done
@@ -35,8 +44,17 @@ function wait_for_balance()
{
msg="wait until $1's balance reaches $2"
cmd="./run_electrum --regtest -D /tmp/$1"
+ declare -i timeout_sec=30
+ declare -i elapsed_sec=0
+
while balance=$($cmd getbalance | jq '[.confirmed, .unconfirmed] | to_entries | map(select(.value != null).value) | map(tonumber) | add ') && (( $(echo "$balance < $2" | bc -l) )); do
+ if ((elapsed_sec > timeout_sec)); then
+ printf "Timeout of %i s exceeded\n" "$elapsed_sec"
+ exit 1
+ fi
+
sleep 1
+ elapsed_sec=$((elapsed_sec + 1))
msg="$msg."
printf "$msg\r"
done
@@ -47,8 +65,17 @@ function wait_until_channel_open()
{
msg="wait until $1 sees channel open"
cmd="./run_electrum --regtest -D /tmp/$1"
+ declare -i timeout_sec=30
+ declare -i elapsed_sec=0
+
while channel_state=$($cmd list_channels | jq '.[0] | .state' | tr -d '"') && [ $channel_state != "OPEN" ]; do
+ if ((elapsed_sec > timeout_sec)); then
+ printf "Timeout of %i s exceeded\n" "$elapsed_sec"
+ exit 1
+ fi
+
sleep 1
+ elapsed_sec=$((elapsed_sec + 1))
msg="$msg."
printf "$msg\r"
done
@@ -59,8 +86,17 @@ function wait_until_channel_closed()
{
msg="wait until $1 sees channel closed"
cmd="./run_electrum --regtest -D /tmp/$1"
+ declare -i timeout_sec=30
+ declare -i elapsed_sec=0
+
while [[ $($cmd list_channels | jq '.[0].state' | tr -d '"') != "CLOSED" ]]; do
+ if ((elapsed_sec > timeout_sec)); then
+ printf "Timeout of %i s exceeded\n" "$elapsed_sec"
+ exit 1
+ fi
+
sleep 1
+ elapsed_sec=$((elapsed_sec + 1))
msg="$msg."
printf "$msg\r"
done
@@ -71,8 +107,17 @@ function wait_until_preimage()
{
msg="wait until $1 has preimage for $2"
cmd="./run_electrum --regtest -D /tmp/$1"
+ declare -i timeout_sec=30
+ declare -i elapsed_sec=0
+
while [[ $($cmd get_invoice $2 | jq '.preimage' | tr -d '"') == "null" ]]; do
+ if ((elapsed_sec > timeout_sec)); then
+ printf "Timeout of %i s exceeded\n" "$elapsed_sec"
+ exit 1
+ fi
+
sleep 1
+ elapsed_sec=$((elapsed_sec + 1))
msg="$msg."
printf "$msg\r"
done
@@ -82,8 +127,17 @@ function wait_until_preimage()
function wait_until_spent()
{
msg="wait until $1:$2 is spent"
+ declare -i timeout_sec=30
+ declare -i elapsed_sec=0
+
while [[ $($bitcoin_cli gettxout $1 $2) ]]; do
+ if ((elapsed_sec > timeout_sec)); then
+ printf "Timeout of %i s exceeded\n" "$elapsed_sec"
+ exit 1
+ fi
+
sleep 1
+ elapsed_sec=$((elapsed_sec + 1))
msg="$msg."
printf "$msg\r"
done
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.