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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:
env:
DASHVERSION: "23.1.0"
TEST_DATA_REPO: "dashpay/regtest-blockchain"
TEST_DATA_VERSION: "v0.0.3"
TEST_DATA_VERSION: "v0.0.4"

jobs:
test:
Expand Down
41 changes: 24 additions & 17 deletions contrib/setup-dashd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Environment variables:
DASHVERSION - Dash Core version (default: 23.1.0)
TEST_DATA_VERSION - Test data release version (default: v0.0.3)
TEST_DATA_VERSION - Test data release version (default: v0.0.4)
TEST_DATA_REPO - GitHub repo for test data (default: dashpay/regtest-blockchain)
CACHE_DIR - Cache directory (default: ~/.rust-dashcore-test)
"""
Expand All @@ -22,7 +22,7 @@

# Keep these defaults in sync with .github/workflows/build-and-test.yml
DASHVERSION = os.environ.get("DASHVERSION", "23.1.0")
TEST_DATA_VERSION = os.environ.get("TEST_DATA_VERSION", "v0.0.3")
TEST_DATA_VERSION = os.environ.get("TEST_DATA_VERSION", "v0.0.4")
TEST_DATA_REPO = os.environ.get("TEST_DATA_REPO", "dashpay/regtest-blockchain")


Expand Down Expand Up @@ -115,23 +115,26 @@ def setup_dashd(cache_dir):
return dashd_bin


VARIANTS = ["regtest-40000", "regtest-200"]
# Each entry maps a variant directory name to a marker path (relative to that
# directory) used as a cache hit / extraction-success check. Single-node
# variants ship a `regtest/blocks` subdirectory; the masternode network ships a
# top-level `network.json` plus per-node datadirs.
VARIANTS = {
"regtest-40000": "regtest/blocks",
"regtest-200": "regtest/blocks",
"regtest-mn": "network.json",
}


def setup_test_data(cache_dir, variant):
"""Download and extract a single test blockchain variant.

Args:
cache_dir: Root cache directory for all test assets.
variant: Directory name of the test data (e.g. "regtest-40000" or "regtest-200").
"""
def setup_test_data(cache_dir, variant, marker_relpath):
"""Download and extract a single test blockchain variant."""
parent_dir = os.path.join(cache_dir, f"regtest-blockchain-{TEST_DATA_VERSION}")
test_data_dir = os.path.join(parent_dir, variant)
blocks_dir = os.path.join(test_data_dir, "regtest", "blocks")
marker_path = os.path.join(test_data_dir, marker_relpath)

if os.path.isdir(blocks_dir):
if os.path.exists(marker_path):
log(f"Test blockchain data {variant} ({TEST_DATA_VERSION}) already available")
return
return test_data_dir

log(f"Downloading test blockchain data {variant} ({TEST_DATA_VERSION})...")
os.makedirs(parent_dir, exist_ok=True)
Expand All @@ -143,26 +146,30 @@ def setup_test_data(cache_dir, variant):
extract(archive_path, parent_dir)
os.remove(archive_path)

if not os.path.isdir(blocks_dir):
sys.exit(f"Expected blocks directory not found after extraction: {blocks_dir}")
if not os.path.exists(marker_path):
sys.exit(f"Expected marker not found after extraction: {marker_path}")

log(f"Downloaded test data to {test_data_dir}")
return test_data_dir


def main():
cache_dir = get_cache_dir()
os.makedirs(cache_dir, exist_ok=True)

dashd_path = setup_dashd(cache_dir)
for variant in VARIANTS:
setup_test_data(cache_dir, variant)
variant_dirs = {
variant: setup_test_data(cache_dir, variant, marker)
for variant, marker in VARIANTS.items()
}

datadir = os.path.join(cache_dir, f"regtest-blockchain-{TEST_DATA_VERSION}")

# GITHUB_ENV expects bare NAME=value; shell `eval` needs `export NAME=value`.
prefix = "" if os.environ.get("GITHUB_ACTIONS") == "true" else "export "
print(f"{prefix}DASHD_PATH={dashd_path}")
print(f"{prefix}DASHD_TEST_DATA={datadir}")
print(f"{prefix}DASHD_MN_DATADIR={variant_dirs['regtest-mn']}")


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions dash-spv/src/test_utils/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub struct TestEventHandler {

impl TestEventHandler {
pub fn new() -> Self {
let (sync_tx, _) = broadcast::channel(256);
let (network_tx, _) = broadcast::channel(256);
let (sync_tx, _) = broadcast::channel(10000);
let (network_tx, _) = broadcast::channel(10000);
let (progress_tx, _) = watch::channel(SyncProgress::default());
let (wallet_tx, _) = broadcast::channel(256);
let (wallet_tx, _) = broadcast::channel(10000);
Self {
sync_tx,
network_tx,
Expand Down
Loading
Loading