feat(tests): wait for fork resolution in tx checks - #3715
Merged
Merged
Conversation
Temporary forks are more frequent on loaded Leios testnets. A tx lost in a fork makes tests, especially long ones, fail much later with a confusing error. Replace `check_missing_utxos` with `check_tx_on_all_nodes`, which checks the first output of the tx on all nodes. Outputs of a tx are either all on the chain or none, so checking one output is enough. When the tx is missing on some nodes, retry quietly once, as a node can be just a bit behind with block propagation. Then wait for the nodes to reach the same chain tip and for 3 more blocks, as the tx can still get into a block from a mempool of a node on the winning chain. The block counting starts again when the nodes fork again. Fail when the tx is still missing after that, or when the nodes don't converge within the timeout (by default 20 average block times, at least 60 seconds). Also call the check after state changing txs in shared delegation and governance helpers, and in long running staking, pool, BLS and governance tests. In tests that need the tx in the same epoch, check the epoch after the tx check, as the tx can get into a block after the epoch boundary when there was a fork. The `assert tx_raw_dereg` in `test_redelegation` narrows the type for mypy. The stake address is registered at that point, so `None` would mean a bug.
mkoura
requested
a lite review from Copilot
and removed request for
saratomaz
September 25, 2026 15:57
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the convergence reset, timeout enforcement, and cleanup-finalizer issues before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
This pull request adds fork-aware transaction consistency checks across the Cardano node test suite, waiting for convergence before reporting missing transactions.
Changes:
- Replaces UTxO-only checks with
check_tx_on_all_nodes. - Adds retry, convergence, and post-convergence block waiting.
- Applies checks across governance, delegation, staking, pool, BLS, Plutus, and transaction tests.
- Reorders epoch checks and narrows optional deregistration transaction types.
| File | Reviewed changes |
|---|---|
cardano_node_tests/utils/node_consistency.py |
Implements fork-aware transaction polling. |
cardano_node_tests/utils/governance_utils.py |
Checks DRep registration transactions. |
cardano_node_tests/utils/governance_setup.py |
Checks governance setup transactions. |
cardano_node_tests/tests/tests_plutus/test_spend_datum_raw.py |
Updates Plutus transaction checks. |
cardano_node_tests/tests/tests_plutus/test_spend_datum_build.py |
Updates datum transaction checks. |
cardano_node_tests/tests/tests_plutus/test_spend_build.py |
Updates spending consistency checks. |
cardano_node_tests/tests/tests_plutus/test_mint_raw.py |
Updates minting consistency checks. |
cardano_node_tests/tests/tests_plutus/test_mint_build.py |
Updates mint build checks. |
cardano_node_tests/tests/tests_plutus/test_delegation.py |
Adds delegation transaction checks. |
cardano_node_tests/tests/tests_plutus_v2/test_spend_secp256k1_build.py |
Updates spending checks. |
cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_raw.py |
Updates reference-input checks. |
cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_build.py |
Updates reference-input build checks. |
cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_raw.py |
Updates minting checks. |
cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_build.py |
Updates mint build checks. |
cardano_node_tests/tests/tests_plutus_v2/test_mint_raw.py |
Updates raw mint checks. |
cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_build.py |
Checks successful negative-mint transactions. |
cardano_node_tests/tests/tests_plutus_v2/test_mint_build.py |
Updates mint build checks. |
cardano_node_tests/tests/tests_plutus_v2/mint_raw.py |
Updates shared mint helper checks. |
cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py |
Adds treasury transaction checks. |
cardano_node_tests/tests/tests_conway/test_treasury_donation.py |
Updates donation checks. |
cardano_node_tests/tests/tests_conway/test_offchain_voting_anchor.py |
Adds proposal transaction checks. |
cardano_node_tests/tests/tests_conway/test_no_confidence.py |
Adds governance transaction checks. |
cardano_node_tests/tests/tests_conway/test_info.py |
Adds governance transaction checks. |
cardano_node_tests/tests/tests_conway/test_hardfork.py |
Adds hardfork transaction checks. |
cardano_node_tests/tests/tests_conway/test_drep.py |
Adds delegation transaction checks. |
cardano_node_tests/tests/tests_conway/test_committee.py |
Adds committee transaction checks. |
cardano_node_tests/tests/tests_conway/conway_common.py |
Adds shared governance transaction checks. |
cardano_node_tests/tests/test_tx_basic.py |
Updates basic transaction checks. |
cardano_node_tests/tests/test_staking_rewards.py |
Adds checks to long-running staking flows. |
cardano_node_tests/tests/test_staking_no_rewards.py |
Adds staking and pool transaction checks. |
cardano_node_tests/tests/test_scripts.py |
Updates script transaction checks. |
cardano_node_tests/tests/test_pools.py |
Adds pool transaction checks. |
cardano_node_tests/tests/test_native_tokens.py |
Updates token transaction checks. |
cardano_node_tests/tests/test_delegation.py |
Adds delegation transaction checks. |
cardano_node_tests/tests/test_bls_rotation.py |
Adds BLS transaction checks. |
cardano_node_tests/tests/test_bls_keys.py |
Adds pool registration checks. |
cardano_node_tests/tests/delegation.py |
Adds shared delegation checks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Temporary forks are more frequent on loaded Leios testnets. A tx lost in a fork makes tests, especially long ones, fail much later with a confusing error.
Replace
check_missing_utxoswithcheck_tx_on_all_nodes, which checks the first output of the tx on all nodes. Outputs of a tx are either all on the chain or none, so checking one output is enough.When the tx is missing on some nodes, retry quietly once, as a node can be just a bit behind with block propagation. Then wait for the nodes to reach the same chain tip and for 3 more blocks, as the tx can still get into a block from a mempool of a node on the winning chain. The block counting starts again when the nodes fork again. Fail when the tx is still missing after that, or when the nodes don't converge within the timeout (by default 20 average block times, at least 60 seconds).
Also call the check after state changing txs in shared delegation and governance helpers, and in long running staking, pool, BLS and governance tests. In tests that need the tx in the same epoch, check the epoch after the tx check, as the tx can get into a block after the epoch boundary when there was a fork.
The
assert tx_raw_deregintest_redelegationnarrows the type for mypy. The stake address is registered at that point, soNonewould mean a bug.