Skip to content

Improve applyCheck and TestAccount test utilites. - #5439

Merged
dmkozh merged 2 commits into
stellar:masterfrom
dmkozh:test_apply_check_upd
Sep 21, 2026
Merged

dmkozh merged 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 Resolved
Comment thread src/simulation/LoadGenerator.cpp Resolved
Comment thread src/test/TestUtils.cpp Resolved
Comment thread src/test/TxTests.cpp Resolved
Comment thread src/test/TestAccount.cpp Resolved
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 Resolved
Comment thread src/herder/TxSetFrame.h Resolved
Comment thread src/simulation/TxGenerator.h Resolved
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.

@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.

@SirTyson SirTyson 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.

Overall LGTM, thanks for cleaning up the tests! One issue, I think we may have dropped some recorded meta checks in tests that moved to using closeLedger.

Comment thread src/herder/TxSetFrame.cpp Resolved
Comment thread src/test/TxTests.cpp Resolved
Copilot AI review requested due to automatic review settings September 18, 2026 00:26
@dmkozh
dmkozh force-pushed the test_apply_check_upd branch from e270465 to f23ada1 Compare September 18, 2026 00:26

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.

🟡 Changes recommended

applyCheck still validates protocol-19+ ledger preconditions against LCL instead of the ledger being closed.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 66/84 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/test/TxTests.cpp Resolved
`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.
Copilot AI review requested due to automatic review settings September 18, 2026 22:00
@dmkozh
dmkozh force-pushed the test_apply_check_upd branch from f23ada1 to a4a8a6a Compare September 18, 2026 22:00
@dmkozh
dmkozh enabled auto-merge September 18, 2026 22:00

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

🔵 Needs a closer look

It changes central transaction-test semantics across many protocol versions and regenerates extensive golden metadata, warranting final human validation.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

@dmkozh
dmkozh added this pull request to the merge queue Sep 21, 2026
Merged via the queue into stellar:master with commit e1085a8 Sep 21, 2026
82 of 86 checks passed
@dmkozh
dmkozh deleted the test_apply_check_upd branch September 21, 2026 18:48
sisuresh added a commit to sisuresh/stellar-core that referenced this pull request Sep 22, 2026
stellar#5439 changed the applyCheck and TestAccount test helpers, which changes the
meta of 7 TxResultsTests leaves and 1 InvokeHostFunctionTests leaf per tier.

Claude-Session: https://claude.ai/code/session_01Rq9SZEScpZhaDqJpqjXu6b
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.

3 participants