Skip to content

Comments

Fix BeforeJSON/AfterJSON swap in AddLedgerEntryChangeJSON#603

Merged
tamirms merged 1 commit intomainfrom
fix-json-diff
Feb 18, 2026
Merged

Fix BeforeJSON/AfterJSON swap in AddLedgerEntryChangeJSON#603
tamirms merged 1 commit intomainfrom
fix-json-diff

Conversation

@tamirms
Copy link
Contributor

@tamirms tamirms commented Feb 18, 2026

What

After was incorrectly assigned to l.BeforeJSON instead of l.AfterJSON, causing JSON-format simulation responses to return the post-transaction state in the before field and a null after field for updated ledger entries. The XDR path was correct.

Also update the test to use distinct Before/After data for the update case and assert both fields directly, so this class of bug is caught.

Known limitations

[N/A]

diff.After was incorrectly assigned to l.BeforeJSON instead of
l.AfterJSON, causing JSON-format simulation responses to return the
post-transaction state in the before field and a null after field for
updated ledger entries. The XDR path was correct.

Also update the test to use distinct Before/After data for the update
case and assert both fields directly, so this class of bug is caught.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes JSON-format simulation state change responses where AfterJSON was accidentally written into BeforeJSON, leading to swapped/null fields for updated ledger entries (while XDR output remained correct).

Changes:

  • Correct AddLedgerEntryChangeJSON to assign diff.After into l.AfterJSON (not l.BeforeJSON).
  • Strengthen TestLedgerEntryChange by using distinct before/after ledger entry data for updates and asserting BeforeJSON/AfterJSON explicitly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/stellar-rpc/internal/methods/simulate_transaction.go Fixes JSON field assignment for post-state (AfterJSON) in ledger entry changes.
cmd/stellar-rpc/internal/methods/simulate_transaction_test.go Updates tests to catch Before/After JSON swaps by asserting distinct expected values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tamirms tamirms merged commit dcc5896 into main Feb 18, 2026
52 checks passed
@tamirms tamirms deleted the fix-json-diff branch February 18, 2026 12:34
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