Skip to content

refactor: split unrelated helpers out of tests/common - #3703

Merged
mkoura merged 3 commits into
masterfrom
split_tests_common
Sep 21, 2026
Merged

mkoura merged 3 commits into
masterfrom
split_tests_common

Conversation

@mkoura

@mkoura mkoura commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Over time, everything that was too test- or pytest-specific to live in
cardano_node_tests/utils/ ended up in cardano_node_tests/tests/common.py, and
the module grew into a collection of unrelated functionality. This splits the
three largest self-contained chunks into their own modules.

tests/common.py shrinks from 734 to 211 lines. No behavior changes - the moves
are pure renames of the qualifying module, plus the removal of dead code.

New modules

  • tests/markers.py - declarative pytest metadata only: the skipif
    conditions, the parametrizations, the XdSplits enum and the Byron-specific
    marks.
  • tests/addrs_common.py - helpers that create and fund payment addresses and
    pool users, together with the related get_conway_address_deposit.
  • utils/node_consistency.py - check_missing_utxos and fail_on_fork. These
    have no pytest dependency and are usable as framework code, so they go to
    utils/ rather than staying under tests/.

What stays in tests/common.py

Test IDs and cluster fixtures (get_test_id, get_fixture_cluster_obj), the
epoch interval constants, the paths and public URLs of the test data files, and
the remaining small helpers (unique_time_str, hypothesis_settings,
match_blocker, is_fee_in_interval, allow_unstable_error_messages).

Removed / privatized

  • Dropped PARAM_OFFLINE_BUILD_METHOD, which had no users.
  • Privatized COMPAT_ERAS, PLUTUSV3_UNUSABLE, get_nodes_missing_utxos and
    detect_fork, which are used only within their new modules.

No compatibility re-exports are left behind in tests/common.py, so all call
sites are updated in place. This is what makes the diff large; each commit is a
mechanical, reviewable rename of one group of symbols.

Move the `skipif` conditions, parametrizations, the `XdSplits` enum and
the Byron-specific marks from `tests/common.py` into a new
`tests/markers.py`, so that `common.py` no longer mixes declarative
pytest metadata with helper functions.

Drop the unused `PARAM_OFFLINE_BUILD_METHOD` and privatize
`COMPAT_ERAS` and `PLUTUSV3_UNUSABLE`, which have no users outside of
the new module.
Move the helpers that create and fund payment addresses and pool users
from `tests/common.py` into a new `tests/addrs_common.py`, together with
the related `get_conway_address_deposit`.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The extraction and call-site updates are mechanically consistent; only a minor private-method naming issue was identified.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Refactors the oversized tests/common.py into focused modules while updating all affected test call sites.

Changes:

  • Extracts pytest markers and parametrizations into tests/markers.py.
  • Extracts address and pool-user helpers into tests/addrs_common.py.
  • Moves node consistency checks into utils/node_consistency.py.
File Description
cardano_node_tests/​tests/​common.py Retains shared test IDs, fixtures, constants, and small helpers.
cardano_node_tests/​tests/​addrs_common.py Adds extracted address and pool-user helpers.
cardano_node_tests/​tests/​markers.py Adds extracted pytest markers and parametrizations.
cardano_node_tests/​utils/​node_consistency.py Adds extracted UTxO and fork consistency checks.
cardano_node_tests/​tests/​delegation.py Updates address-deposit helper references.
cardano_node_tests/​tests/​test_addr_registration.py Updates extracted helper and marker references.
cardano_node_tests/​tests/​test_blocks.py Updates address helpers and xdist markers.
cardano_node_tests/​tests/​test_chain_transactions.py Updates payment-address helper usage.
cardano_node_tests/​tests/​test_configuration.py Updates era, Byron, and xdist markers.
cardano_node_tests/​tests/​test_dbsync.py Updates xdist marker usage.
cardano_node_tests/​tests/​test_delegation.py Updates address helpers, deposits, and markers.
cardano_node_tests/​tests/​test_env_network_id.py Updates address and build marker references.
cardano_node_tests/​tests/​test_kes.py Updates markers and node consistency helper usage.
cardano_node_tests/​tests/​test_ledger_state.py Updates era marker usage.
cardano_node_tests/​tests/​test_leios_blocks.py Updates testnet marker usage.
cardano_node_tests/​tests/​test_metrics.py Updates era marker usage.
cardano_node_tests/​tests/​test_mir_certs.py Updates pool-user and build marker references.
cardano_node_tests/​tests/​test_mnemonic.py Updates era marker usage.
cardano_node_tests/​tests/​test_native_tokens.py Updates address, marker, and consistency helper references.
cardano_node_tests/​tests/​test_node_upgrade.py Updates address, pool-user, and build marker references.
cardano_node_tests/​tests/​test_pool_saturation.py Updates xdist marker usage.
cardano_node_tests/​tests/​test_pools.py Updates pool-user, deposit, and marker references.
cardano_node_tests/​tests/​test_reconnect.py Updates address and testnet marker references.
cardano_node_tests/​tests/​test_rollback.py Updates address and testnet marker references.
cardano_node_tests/​tests/​test_scripts.py Updates address, marker, and consistency helper references.
cardano_node_tests/​tests/​test_socket_path.py Updates address and build marker references.
cardano_node_tests/​tests/​test_staking_no_rewards.py Updates address-deposit and build marker references.
cardano_node_tests/​tests/​test_staking_rewards.py Updates address-deposit and testnet marker references.
cardano_node_tests/​tests/​test_tx_basic.py Updates address, marker, and consistency helper references.
cardano_node_tests/​tests/​test_tx_fees.py Updates address and deposit helper references.
cardano_node_tests/​tests/​test_tx_many_utxos.py Updates payment-address helper usage.
cardano_node_tests/​tests/​test_tx_mempool.py Updates address and xdist marker references.
cardano_node_tests/​tests/​test_tx_metadata.py Updates address and build marker references.
cardano_node_tests/​tests/​test_tx_negative.py Updates pool-user and build marker references.
cardano_node_tests/​tests/​test_tx_unbalanced.py Updates address and build marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​mint_raw.py Updates consistency helper usage.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_negative_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_negative_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_raw.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_secp256k1_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_secp256k1_raw.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_collateral_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_collateral_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_compat_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_compat_raw.py Updates address helper usage.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_datum_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_datum_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_ref_inputs_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_ref_inputs_raw.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_ref_scripts_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_ref_scripts_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_secp256k1_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_secp256k1_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_delegation.py Updates address, deposit, and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_lobster.py Updates address and build marker references.
cardano_node_tests/​tests/​tests_plutus/​test_mint_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus/​test_mint_negative_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_mint_negative_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_mint_raw.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus/​test_spend_build.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_spend_compat_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_spend_compat_raw.py Updates address helper usage.
cardano_node_tests/​tests/​tests_plutus/​test_spend_datum_build.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus/​test_spend_datum_raw.py Updates address, markers, and consistency checks.
cardano_node_tests/​tests/​tests_plutus/​test_spend_negative_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_spend_negative_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus/​test_spend_raw.py Updates address and marker references.
cardano_node_tests/​tests/​tests_plutus_v3/​test_mint_build.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_plutus_v3/​test_spend_build.py Updates address and marker references.
cardano_node_tests/​tests/​tests_conway/​test_committee.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_conway/​test_constitution.py Updates pool-user and xdist marker references.
cardano_node_tests/​tests/​tests_conway/​test_conway.py Updates pool-user and marker references.
cardano_node_tests/​tests/​tests_conway/​test_drep.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_conway/​test_guardrails.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_conway/​test_hardfork.py Updates pool-user and xdist marker references.
cardano_node_tests/​tests/​tests_conway/​test_info.py Updates pool-user helper usage.
cardano_node_tests/​tests/​tests_conway/​test_no_confidence.py Updates pool-user and xdist marker references.
cardano_node_tests/​tests/​tests_conway/​test_offchain_voting_anchor.py Updates address and pool-user helper usage.
cardano_node_tests/​tests/​tests_conway/​test_pparam_update.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_conway/​test_treasury_donation.py Updates address, marker, and consistency helper references.
cardano_node_tests/​tests/​tests_conway/​test_treasury_withdrawals.py Updates address, pool-user, and marker references.
cardano_node_tests/​tests/​tests_conway/​test_update_plutusv2_builtins.py Updates address, pool-user, and xdist marker references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cardano_node_tests/tests/test_reconnect.py Outdated
Move `check_missing_utxos` and `fail_on_fork` from `tests/common.py`
into a new `utils/node_consistency.py`. The functions have no pytest
dependency and are usable as framework code.

Privatize `get_nodes_missing_utxos` and `detect_fork`, which are called
only by the two public functions.
@mkoura
mkoura merged commit b8fd259 into master Sep 21, 2026
3 checks passed
@mkoura
mkoura deleted the split_tests_common branch September 21, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants