Skip to content

Add unit test locking in tx getter defensive-copy immutability#941

Merged
sagpatil merged 3 commits intofix/tx-immutability-and-memo-id-validationfrom
copilot/sub-pr-939-again
Mar 17, 2026
Merged

Add unit test locking in tx getter defensive-copy immutability#941
sagpatil merged 3 commits intofix/tx-immutability-and-memo-id-validationfrom
copilot/sub-pr-939-again

Conversation

Copy link

Copilot AI commented Mar 17, 2026

The tx getter on TransactionBase was updated to return a defensive copy (via fromXDR(toXDR())), but no test explicitly verified that mutating the returned object leaves the internal XDR untouched.

Changes

  • New test in test/unit/transaction_test.js: asserts that calling .fee(...) on the object returned by transaction.tx does not alter transaction._tx
it('tx getter returns a defensive copy that does not affect internal XDR', function () {
  const transaction = this.transaction;
  const txCopy = transaction.tx;
  txCopy.fee(StellarBase.xdr.Int64.fromString('999'));

  expect(transaction.tx.fee().toString()).to.equal('100');
});

This closes the gap where the existing tests only verified toEnvelope() isolation, leaving the tx getter's copy semantics untested.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 17, 2026 20:41
Co-authored-by: sagpatil <1414227+sagpatil@users.noreply.github.com>
Co-authored-by: sagpatil <1414227+sagpatil@users.noreply.github.com>
Copilot AI changed the title [WIP] [WIP] Address feedback on mutable tx handle and memo ID validation fix Add unit test locking in tx getter defensive-copy immutability Mar 17, 2026
Copilot AI requested a review from sagpatil March 17, 2026 20:43
@github-actions
Copy link

github-actions bot commented Mar 17, 2026

Size Change: 0 B

Total Size: 3.53 MB

ℹ️ View Unchanged
Filename Size
dist/stellar-base.js 2.6 MB
dist/stellar-base.min.js 921 kB

compressed-size-action

@sagpatil sagpatil marked this pull request as ready for review March 17, 2026 21:54
@sagpatil sagpatil merged commit c0f37ca into fix/tx-immutability-and-memo-id-validation Mar 17, 2026
6 checks passed
@sagpatil sagpatil deleted the copilot/sub-pr-939-again branch March 17, 2026 21:54
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