Testing Setup

For ease of development, the upstream CashScript SDK provides a MockNetwork environment where you can create virtual UTXOs. This has the advantage of not needing any testnet balances, not having to set up contract UTXOs, and not having network latency.

CashScript-Py does not yet provide a full mock network provider. Instead, this repository uses:

  • pytest for automated tests

  • chipnet-based end-to-end (E2E) scenarios for integration coverage

  • cashscript_py_support.utils to reduce funding/cleanup boilerplate when interacting with chipnet

chipnet prerequisites (FAUCET_WIF)

Because chipnet is a real public test network, E2E tests require:

  • network connectivity

  • a funded chipnet private key (tBCH) available via FAUCET_WIF

To obtain a funded WIF, you can use Electron Cash (recommended), a Chipnet faucet, or any wallet that can export a WIF.

For a step-by-step Electron Cash walkthrough, see: Getting started → “Prepare Chipnet funds (FAUCET_WIF)”.

Export FAUCET_WIF

Export the WIF so examples/tests and cashscript_py_support.utils can use it:

  • Linux/macOS:

    • export FAUCET_WIF="your_faucet_wif_here"

  • Windows (PowerShell):

    • $env:FAUCET_WIF = "your_faucet_wif_here"

Notes:

  • Treat FAUCET_WIF like a password: do not commit it to git or paste it into logs/issues.

  • E2E tests may consolidate funds back into a single UTXO after the test session to keep your faucet wallet tidy.

Install dev dependencies

This project uses uv and dependency groups.

  • Runtime deps: uv sync

  • Dev tools: uv sync --group dev

Environment variables

FAUCET_WIF

Many examples/tests use cashscript_py_support.utils, which expects:

  • FAUCET_WIF — a chipnet WIF with tBCH available

CASHSCRIPT_PY_DEBUG

For verbose debug output (preimage/sighash/signature/script details), set:

  • CASHSCRIPT_PY_DEBUG=1

Automated testing (pytest)

Run all tests:

uv run pytest

If you are running E2E tests, ensure FAUCET_WIF is set and funded.

Notes for “mocknet-style” tests

In the upstream SDK, tests can be fully local (virtual UTXOs, fast debug evaluation, assertions on console.log values and require messages).

In CashScript-Py today:

  • tests which need realistic signing/broadcasting use chipnet and live providers

  • debugging is currently lower-level:

    • enable CASHSCRIPT_PY_DEBUG=1 to print preimage/sighash/signature details

    • assert observable outcomes in tests (e.g., tx accepted, expected UTXO set changes)

cashscript_py_support.utils exists to remove much of the “real network” friction and keep tests focused on behavior rather than funding mechanics.