Skip to content

Improve applyCheck and TestAccount test utilites. - #5439

Open
dmkozh wants to merge 2 commits into
stellar:masterfrom
dmkozh:test_apply_check_upd
Open

Improve applyCheck and TestAccount test utilites.#5439
dmkozh wants to merge 2 commits into
stellar:masterfrom
dmkozh:test_apply_check_upd

Conversation

@dmkozh

@dmkozh dmkozh commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

applyCheck now properly closes the ledgers. This both improves the test coverage and prepares us for the future changes that may alter the transaction processing flow. This also avoids testing unrealistic scenarios where invalid transactions were applied to ledgers: these scenarios created wrong expectations, that ultimately ended up hiding a change in protocol behavior (#5431)

TestAccount now always loads the sequence number from the ledger, because transactions that failed validation no longer cause a sequence number bump. Doing this by default is more convenient and straightforward, and also it's less error prone. There is only a handful of tests that create multiple transactions per source account (to ensure it fails validation, or for the legacy protocols) and these manage seq nums manually. Load generation machinery now uses its own CachedTestAccount that has the old caching logic, which is relevant for pre-generating transactions.

Additionally, enforce transaction validation when closeLedger is done with strictOrder. Previously this skipped tx validation, which resulted in tests that would silently drop transactions. This hardens the new tests that need to apply transactions in the same ledger in strict order in order to realistically cover scenarios when transaction is invalidated at apply time by a different transaction.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copilot AI balanced review requested due to automatic review settings September 1, 2026 00:53

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.

Pull request overview

Updates transaction test utilities to use realistic ledger-close behavior and ledger-backed sequence numbers.

Changes:

  • Reworks applyCheck and related transaction tests.
  • Updates TestAccount and transaction generation sequence handling.
  • Adjusts sponsorship, fee-bump, path-payment, Herder, and Soroban tests.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/transactions/test/TxEnvelopeTests.cpp Models apply-time transaction invalidation.
src/transactions/test/SponsorshipTestUtils.cpp Builds transactions immediately before closing ledgers.
src/transactions/test/RevokeSponsorshipTests.cpp Removes manual sequence rollback.
src/transactions/test/PathPaymentTests.cpp Validates malformed transactions without applying them.
src/transactions/test/PathPaymentStrictSendTests.cpp Tests ordered, apply-time failures.
src/transactions/test/ParallelApplyTest.cpp Guards unavailable historical protocols.
src/transactions/test/InvokeHostFunctionTests.cpp Updates sequence and execution-cost expectations.
src/transactions/test/FeeBumpTransactionTests.cpp Exercises fee bumps through ledger close.
src/transactions/test/ClaimableBalanceTests.cpp Uses realistic application and fee accounting.
src/transactions/test/BumpSequenceTests.cpp Captures current bad-sequence behavior.
src/test/TxTests.h Makes applyCheck pointer input const.
src/test/TxTests.cpp Reimplements application through ledger close.
src/test/TestUtils.cpp Tracks sequences for generated transactions.
src/test/TestExceptions.h Adds revoke-sponsorship exceptions.
src/test/TestExceptions.cpp Maps revoke-sponsorship failures to exceptions.
src/test/TestAccount.h Exposes cached sequence state.
src/test/TestAccount.cpp Reloads sequence state from the ledger.
src/simulation/TxGenerator.h Adds explicit sequence parameters.
src/simulation/TxGenerator.cpp Supports caller-provided sequences.
src/simulation/LoadGenerator.cpp Revises synchronization and retry bookkeeping.
src/herder/test/TxSetTests.cpp Supplies explicit sequential transaction numbers.
src/herder/test/HerderTests.cpp Updates sequence and surge-pricing scenarios.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/test/TxTests.cpp Outdated
Comment thread src/transactions/test/ClaimableBalanceTests.cpp Outdated
Comment thread src/simulation/LoadGenerator.cpp Outdated
Comment thread src/test/TestUtils.cpp Outdated
Comment thread src/test/TxTests.cpp Outdated
Comment thread src/test/TestAccount.cpp
Copilot AI review requested due to automatic review settings September 3, 2026 00:29
@dmkozh
dmkozh force-pushed the test_apply_check_upd branch from ccb328a to 8a1da89 Compare September 3, 2026 00:29
@dmkozh
dmkozh force-pushed the test_apply_check_upd branch from 8a1da89 to 462fe25 Compare September 3, 2026 00:30

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.

Pull request overview

Copilot reviewed 65 out of 83 changed files in this pull request and generated 5 comments.

Suppressed comments (2)

src/transactions/test/ClaimableBalanceTests.cpp:883

  • This derives the ID from the account's current ledger sequence, but the balance created by the following transaction is keyed with that transaction's sequence (current + 1; see CreateClaimableBalanceOpFrame.cpp:316-318). The claim therefore targets a nonexistent balance and breaks the create-and-claim-in-one-transaction case. Keep the explicit next sequence when computing the ID.
    src/herder/TxSetFrame.h:139
  • Add the missing space between the identifier and “forces.”

Comment thread src/test/TxTests.cpp
Comment thread src/herder/TxSetFrame.h Outdated
Comment thread src/simulation/TxGenerator.h Outdated
Comment thread src/transactions/test/BumpSequenceTests.cpp Outdated
Comment thread src/transactions/test/PathPaymentStrictSendTests.cpp Outdated
Copilot AI review requested due to automatic review settings September 3, 2026 00:35

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.

Pull request overview

Copilot reviewed 65 out of 83 changed files in this pull request and generated 1 comment.

Suppressed comments (4)

src/transactions/test/BumpSequenceTests.cpp:164

  • Fix the typo in this newly added explanation: “validaition” should be “validation.”
    src/simulation/TxGenerator.h:116
  • The phrase “per account it once” is ungrammatical; this should say “per account at once.”
    src/herder/TxSetFrame.h:122
  • Add the missing space after the inline code span so the generated documentation reads correctly.
    src/herder/TxSetFrame.h:139
  • Add the missing space after the inline code span so this overload's documentation reads correctly as well.

Comment thread src/transactions/test/ClaimableBalanceTests.cpp Outdated
`applyCheck` now properly closes the ledgers. This both improves the test coverage and prepares us for the future changes that may alter the transaction processing flow. This also avoids testing unrealistic scenarios where invalid transactions were applied to ledgers: these scenarios created wrong expectations, that ultimately ended up hiding a change in protocol behavior (stellar#5431)

`TestAccount` now always loads the sequence number from the ledger, because transactions that failed validation no longer cause a sequence number bump. Doing this by default is more convenient and straightforward, and also it's less error prone. There is only a handful of tests that create multiple transactions per source account (to ensure it fails validation, or for the legacy protocols) and these manage seq nums manually. Load generation machinery now uses its own `CachedTestAccount` that has the old caching logic, which is relevant for pre-generating transactions.

Additionally, enforce transaction validation when `closeLedger` is done with `strictOrder`. Previously this skipped tx validation, which resulted in tests that would silently drop transactions. This hardens the new tests that need to apply transactions in the same ledger in strict order in order to realistically cover scenarios when transaction is invalidated at apply time by a different transaction.
@dmkozh
dmkozh force-pushed the test_apply_check_upd branch from 462fe25 to e270465 Compare September 3, 2026 02:30
Copilot AI review requested due to automatic review settings September 3, 2026 02:30

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.

Pull request overview

Copilot reviewed 66 out of 84 changed files in this pull request and generated no new comments.

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