Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/_functions.bitcoincore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
function downloadBitcoinCore() {
# set version
# https://bitcoincore.org/en/download/
bitcoinVersion="29.2"
bitcoinVersion="31.1"

if bitcoin-cli --version | grep $bitcoinVersion >/dev/null; then
echo "# Bitcoin Core $bitcoinVersion is already installed"
Expand Down Expand Up @@ -75,8 +75,8 @@ function downloadBitcoinCore() {
# check binary checksum test
echo "- checksum test"
# get the sha256 value for the corresponding platform from signed hash sum file
bitcoinSHA256=$(grep -i "${binaryName}" SHA256SUMS | cut -d " " -f1)
binaryChecksum=$(sha256sum ${binaryName} | cut -d " " -f1)
bitcoinSHA256=$(awk -v name="${binaryName}" '$2 == name {print $1; exit}' SHA256SUMS)
binaryChecksum=$(sha256sum "${binaryName}" | cut -d " " -f1)
echo "Valid SHA256 checksum should be: ${bitcoinSHA256}"
echo "Downloaded binary SHA256 checksum: ${binaryChecksum}"
if [ "${binaryChecksum}" != "${bitcoinSHA256}" ]; then
Expand Down Expand Up @@ -110,7 +110,8 @@ function installBitcoinCore() {
echo "# Add /home/joinmarket/bitcoin to the local PATH"
echo "PATH=/home/joinmarket/bitcoin:$PATH" | sudo tee -a /home/joinmarket/.profile
fi
installed=$(/home/joinmarket/bitcoin/bitcoind --version | grep -c "Bitcoin Core version")
installed=$(/home/joinmarket/bitcoin/bitcoind --version | \
grep -Fc "Bitcoin Core version v${bitcoinVersion}")
if [ ${installed} -lt 1 ]; then
echo
echo "# BUILD FAILED --> Was not able to install Bitcoin Core"
Expand Down
2 changes: 2 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ file recursively - **to add tests, just drop a new `.bats` file here**, no CI
change needed.

Current coverage:
- `bitcoin-core-version.bats` - pinned Bitcoin Core release, signed manifest
URLs, supported Linux artifact matrix, and verification ordering
- `repository-contracts.bats` - syntax checks for every maintained shell and
Python script, systemd unit structure, and safe config-parser adoption
- `source-conf.bats` - safe parsing of config data, quoting, malformed lines,
Expand Down
36 changes: 36 additions & 0 deletions tests/bitcoin-core-version.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bats

SCRIPT="$BATS_TEST_DIRNAME/../scripts/_functions.bitcoincore.sh"

@test "standalone installer pins Bitcoin Core 31.1" {
grep -Fq 'bitcoinVersion="31.1"' "$SCRIPT"
! grep -Fq 'bitcoinVersion="29.2"' "$SCRIPT"
}

@test "release downloads use the pinned version for signed manifests and binaries" {
grep -Fq 'bitcoin-core-${bitcoinVersion}/SHA256SUMS' "$SCRIPT"
grep -Fq 'bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc' "$SCRIPT"
grep -Fq 'bitcoin-core-${bitcoinVersion}/${binaryName}' "$SCRIPT"
grep -Fq 'binaryName="bitcoin-${bitcoinVersion}-${bitcoinOSversion}.tar.gz"' "$SCRIPT"
}

@test "all JoininBox-supported v31.1 Linux architectures remain mapped" {
grep -Fq 'bitcoinOSversion="arm-linux-gnueabihf"' "$SCRIPT"
grep -Fq 'bitcoinOSversion="aarch64-linux-gnu"' "$SCRIPT"
grep -Fq 'bitcoinOSversion="x86_64-linux-gnu"' "$SCRIPT"
}

@test "signed manifest lookup requires an exact artifact filename" {
grep -Fq 'awk -v name="${binaryName}" '\''$2 == name {print $1; exit}'\'' SHA256SUMS' "$SCRIPT"
! grep -Fq 'grep -i "${binaryName}" SHA256SUMS' "$SCRIPT"
}

@test "post-install smoke check requires the pinned Bitcoin Core version" {
grep -Fq 'grep -Fc "Bitcoin Core version v${bitcoinVersion}"' "$SCRIPT"
}

@test "signature verification precedes binary checksum acceptance" {
signature_line="$(grep -n 'gpg --verify SHA256SUMS.asc' "$SCRIPT" | head -n1 | cut -d: -f1)"
checksum_line="$(grep -n 'binaryChecksum=' "$SCRIPT" | head -n1 | cut -d: -f1)"
[ "$signature_line" -lt "$checksum_line" ]
}
Loading