ci: Download script_assets_test.json for Windows CI
What changed, and why it matters
This change updates Bitcoin Core's Windows continuous integration (CI) scripts to download a test data file used by unit tests. It is a build/test infrastructure fix, not a change to the Bitcoin node software itself, and it does not introduce a security vulnerability.
No security action required. Review as normal CI/test infrastructure change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds a helper download_script_assets() in test/download_utils.py that downloads script_assets_test.json from the bitcoin-core/qa-assets repository. It then calls this helper in the Windows CI Python scripts and sets DIR_UNIT_TEST_DATA so unit tests can find the file. The workflow step order in .github/workflows/ci.yml is also adjusted so the test data is downloaded before unit tests run. There is no modification to consensus, networking, wallet, or cryptographic code.
Changed components
.github/ci-windows-cross.py.github/ci-windows.py.github/workflows/ci.ymltest/download_utils.pyInspect captured patch +40 / −8
diff --git a/.github/ci-windows-cross.py b/.github/ci-windows-cross.py
index 13ca3b49..d7d58d1d 100755
--- a/.github/ci-windows-cross.py
+++ b/.github/ci-windows-cross.py
@@ -10,6 +10,9 @@ import subprocess
import sys
from pathlib import Path
+sys.path.append(str(Path(__file__).resolve().parent.parent / "test"))
+from download_utils import download_script_assets
+
def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
@@ -81,6 +84,9 @@ def prepare_tests():
run(cmd_download_prev_rel)
run([sys.executable, "-m", "pip", "install", "pyzmq"])
+ dest = workspace / "unit_test_data"
+ download_script_assets(dest)
+
def run_functional_tests():
workspace = Path.cwd()
@@ -117,6 +123,8 @@ def run_functional_tests():
def run_unit_tests():
+ workspace = Path.cwd()
+ os.environ["DIR_UNIT_TEST_DATA"] = str(workspace / "unit_test_data")
# Can't use ctest here like other jobs as we don't have a CMake build tree.
commands = [
["./bin/test_bitcoin-qt.exe"],
diff --git a/.github/ci-windows.py b/.github/ci-windows.py
index caa2d52c..d38b087c 100755
--- a/.github/ci-windows.py
+++ b/.github/ci-windows.py
@@ -10,6 +10,9 @@ import subprocess
import sys
from pathlib import Path
+sys.path.append(str(Path(__file__).resolve().parent.parent / "test"))
+from download_utils import download_script_assets
+
def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
@@ -103,10 +106,13 @@ def check_manifests(ci_type):
def prepare_tests(ci_type):
+ workspace = Path.cwd()
if ci_type == "standard":
run([sys.executable, "-m", "pip", "install", "pyzmq"])
+ dest = workspace / "unit_test_data"
+ download_script_assets(dest)
elif ci_type == "fuzz":
- repo_dir = str(Path.cwd() / "qa-assets")
+ repo_dir = str(workspace / "qa-assets")
clone_cmd = [
"git",
"clone",
@@ -120,11 +126,13 @@ def prepare_tests(ci_type):
def run_tests(ci_type):
- build_dir = Path.cwd() / "build"
+ workspace = Path.cwd()
+ build_dir = workspace / "build"
num_procs = str(os.process_cpu_count())
release_bin = build_dir / "bin" / "Release"
if ci_type == "standard":
+ os.environ["DIR_UNIT_TEST_DATA"] = str(workspace / "unit_test_data")
test_envs = {
"BITCOIN_BIN": "bitcoin.exe",
"BITCOIND": "bitcoind.exe",
@@ -157,7 +165,7 @@ def run_tests(ci_type):
"--jobs",
num_procs,
"--quiet",
- f"--tmpdirprefix={Path.cwd()}",
+ f"--tmpdirprefix={workspace}",
"--combinedlogslen=99999999",
*shlex.split(os.environ.get("TEST_RUNNER_EXTRA", "").strip()),
]
@@ -172,7 +180,7 @@ def run_tests(ci_type):
num_procs,
"--loglevel",
"DEBUG",
- str(Path.cwd() / "qa-assets" / "fuzz_corpora"),
+ str(workspace / "qa-assets" / "fuzz_corpora"),
]
run(fuzz_cmd)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ebd0986b..7178c2bd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -432,13 +432,12 @@ jobs:
- name: Check executable manifests
run: py -3 .github/ci-windows-cross.py check_manifests
+ - name: Prepare Windows test environment
+ run: py -3 .github/ci-windows-cross.py prepare_tests
+
- name: Run unit tests
run: py -3 .github/ci-windows-cross.py run_unit_tests
- - name: Prepare Windows test environment
- run: |
- py -3 .github/ci-windows-cross.py prepare_tests
-
- name: Run functional tests
env:
TEST_RUNNER_EXTRA: "--timeout-factor=${{ env.TEST_RUNNER_TIMEOUT_FACTOR }} ${{ case(github.event_name == 'pull_request', '', '--extended') }}"
diff --git a/test/download_utils.py b/test/download_utils.py
index a4f94d8d..c7fd6cf0 100644
--- a/test/download_utils.py
+++ b/test/download_utils.py
@@ -4,6 +4,7 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
+import sys
import time
import urllib.request
@@ -46,3 +47,19 @@ def download_from_url(url, archive):
raise RuntimeError(f"Download incomplete: expected {total_size} bytes, got {progress_bytes} bytes")
print('\n', flush=True, end="") # Flush to avoid error output on the same line.
+
+
+def download_script_assets(script_assets_dir):
+ script_assets_dir.mkdir(parents=True, exist_ok=True)
+ script_assets = script_assets_dir / "script_assets_test.json"
+ url = "https://github.com/bitcoin-core/qa-assets/raw/main/unit_test_data/script_assets_test.json"
+ try:
+ download_from_url(url, script_assets)
+ except Exception as e:
+ print(f"\nDownload failed: {e}", file=sys.stderr)
+ print("Retrying download after failure ...", file=sys.stderr)
+ time.sleep(12)
+ try:
+ download_from_url(url, script_assets)
+ except Exception as e2:
+ sys.exit(e2)
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.