Skip to content

Commit 4caa10b

Browse files
committed
Merge bitcoin/bitcoin#28628: lint: Include test_utxo_snapshots in lint_shell, fix linter errors
348e79f lint: Include test_utxo_snapshots in lint_shell (Fabian Jahr) Pull request description: jamesob excluded `test_utxo_snapshots.sh` from the shell linter with this explanation: "Add the script to the shellcheck exception list since the quoted variables rule needs to be violated in order to get bitcoind to pick up on $EARLY_IBD_FLAGS." However, macrofake pointed out that single lines can be excluded from linting. This fixes one fixable rule violation, excludes the rest of the offending lines from the linter and then removes the exclusion of the `test_utxo_snapshots.sh` file. Also adds documentation. ACKs for top commit: Empact: ACK 348e79f maflcko: lgtm ACK 348e79f pablomartin4btc: tACK 348e79f Tree-SHA512: a904cc1cc3c94488dfbd39ea69a3ef17259f991708a797009001669448fef81eed086ecbce1ec433988d88baef293849698e2e0eb86a969b949cc7ef93af7b4b
2 parents 76d8957 + 348e79f commit 4caa10b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

contrib/devtools/test_utxo_snapshots.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111
# loaded. We see the background validation chainstate removed after validation
1212
# completes.
1313
#
14+
# The shellcheck rule SC2086 (quoted variables) disablements are necessary
15+
# since this rule needs to be violated in order to get bitcoind to pick up on
16+
# $EARLY_IBD_FLAGS for the script to work.
1417

1518
export LC_ALL=C
1619
set -e
1720

1821
BASE_HEIGHT=${1:-30000}
1922
INCREMENTAL_HEIGHT=20000
20-
FINAL_HEIGHT=$(($BASE_HEIGHT + $INCREMENTAL_HEIGHT))
23+
FINAL_HEIGHT=$((BASE_HEIGHT + INCREMENTAL_HEIGHT))
2124

2225
SERVER_DATADIR="$(pwd)/utxodemo-data-server-$BASE_HEIGHT"
2326
CLIENT_DATADIR="$(pwd)/utxodemo-data-client-$BASE_HEIGHT"
@@ -107,12 +110,14 @@ read -p "Press [enter] to continue" _
107110

108111
echo
109112
echo "-- IBDing the blocks (height=$BASE_HEIGHT) required to the server node..."
113+
# shellcheck disable=SC2086
110114
./src/bitcoind -logthreadnames=1 $SERVER_PORTS \
111115
-datadir="$SERVER_DATADIR" $EARLY_IBD_FLAGS -stopatheight="$BASE_HEIGHT" >/dev/null
112116

113117
echo
114118
echo "-- Creating snapshot at ~ height $BASE_HEIGHT ($UTXO_DAT_FILE)..."
115119
server_sleep_til_shutdown # wait for stopatheight to be hit
120+
# shellcheck disable=SC2086
116121
./src/bitcoind -logthreadnames=1 $SERVER_PORTS \
117122
-datadir="$SERVER_DATADIR" $EARLY_IBD_FLAGS -connect=0 -listen=0 >/dev/null &
118123
SERVER_PID="$!"
@@ -137,11 +142,13 @@ echo " {${RPC_BASE_HEIGHT}, AssumeutxoHash{uint256S(\"0x${RPC_AU}\")}, ${RPC_N
137142
echo
138143
echo
139144
echo "-- IBDing more blocks to the server node (height=$FINAL_HEIGHT) so there is a diff between snapshot and tip..."
145+
# shellcheck disable=SC2086
140146
./src/bitcoind $SERVER_PORTS -logthreadnames=1 -datadir="$SERVER_DATADIR" \
141147
$EARLY_IBD_FLAGS -stopatheight="$FINAL_HEIGHT" >/dev/null
142148

143149
echo
144150
echo "-- Starting the server node to provide blocks to the client node..."
151+
# shellcheck disable=SC2086
145152
./src/bitcoind $SERVER_PORTS -logthreadnames=1 -debug=net -datadir="$SERVER_DATADIR" \
146153
$EARLY_IBD_FLAGS -connect=0 -listen=1 >/dev/null &
147154
SERVER_PID="$!"
@@ -165,6 +172,7 @@ read -p "When you're ready for all this, hit [enter]" _
165172

166173
echo
167174
echo "-- Starting the client node to get headers from the server, then load the snapshot..."
175+
# shellcheck disable=SC2086
168176
./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" \
169177
-connect=0 -addnode=127.0.0.1:$SERVER_PORT -debug=net $EARLY_IBD_FLAGS >/dev/null &
170178
CLIENT_PID="$!"
@@ -189,6 +197,7 @@ echo
189197
read -p "Press [enter] to continue"
190198

191199
client_sleep_til_boot
200+
# shellcheck disable=SC2086
192201
./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" -connect=0 \
193202
-addnode=127.0.0.1:$SERVER_PORT "$EARLY_IBD_FLAGS" >/dev/null &
194203
CLIENT_PID="$!"

test/lint/lint-shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def main():
7070
reg = re.compile(r'src/[leveldb,secp256k1,minisketch]')
7171

7272
def should_exclude(fname: str) -> bool:
73-
return bool(reg.match(fname)) or 'test_utxo_snapshots.sh' in fname
73+
return bool(reg.match(fname))
7474

7575
# remove everything that doesn't match this regex
7676
files[:] = [file for file in files if not should_exclude(file)]

0 commit comments

Comments
 (0)