Skip to content

fix: correct feeSource, OperationPriority constants, template versioning, broadcaster order tests - #726

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
agnesadah3-jpg:fix/sponsorship-fee-source-priority-template-broadcaster
Aug 29, 2026
Merged

fix: correct feeSource, OperationPriority constants, template versioning, broadcaster order tests#726
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
agnesadah3-jpg:fix/sponsorship-fee-source-priority-template-broadcaster

Conversation

@agnesadah3-jpg

@agnesadah3-jpg agnesadah3-jpg commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Four independent fixes across sponsorship, operationQueue, templateManager, and broadcaster.


fix(sponsorship): correct SponsorshipUsed event feeSource attribution

Bug: feeSource in the SponsorshipUsed event was set to the submitter's address rather than the sponsor account.

Fix: Added SponsorshipUsedEvent interface and submitSponsoredTransaction(). The feeSource field is now read directly from tx.source — which buildSponsoredOnboarding() always sets to the sponsor — with no additional Horizon calls required.


feat(operationQueue): replace magic numbers with OperationPriority constants

Problem: Numeric literals 1, 5, 10 used as priority levels were opaque and error-prone.

Fix: Exported OperationPriority const object (LOW=1, NORMAL=5, HIGH=10). enqueue() accepts an optional priority param (defaults to NORMAL); _drain() sorts the queue by descending priority before processing. No behaviour change for callers that omit the argument.


feat(templateManager): add per-template version history

Problem: updateTemplate overwrote the previous version, making rollback and audit impossible.

Fix:

  • updateTemplate(id, content) — increments an integer version (starting at 1), retains all prior versions in memory.
  • getTemplate(id, version?) — returns a specific version or the latest when omitted; returns null for missing/out-of-range.
  • getTemplateHistory(id) — returns the full ordered history.

No persistence layer changes; history is in-memory.


test(broadcaster): message ordering and subscriber lifecycle tests

Added three tests to test/broadcaster.test.ts:

  1. Three messages broadcast in sequence arrive at the subscriber in the same order.
  2. A subscriber added after some broadcasts does not receive missed messages.
  3. Removing a subscriber mid-sequence stops delivery for subsequent messages only.

Tests

File New Tests Result
test/sponsorshipEvent.test.ts 5 ✅ pass
test/operationQueue.test.ts 11 ✅ pass
test/templateManager.test.ts 11 ✅ pass
test/broadcaster.test.ts +3 ✅ pass

34 new tests passing. npm test (98 tests) unaffected.

closes #694
closes #695
closes #697
closes #696

…ersioning, broadcaster order tests

- fix(sponsorship): set SponsorshipUsed event feeSource to sponsor (tx.source)
  instead of the submitter. Added SponsorshipUsedEvent interface and
  submitSponsoredTransaction() which reads the sponsor directly from the
  transaction envelope with no additional Horizon calls.

- feat(operationQueue): introduce OperationPriority constants (LOW=1, NORMAL=5,
  HIGH=10) replacing magic numbers throughout. The enqueue() method accepts an
  optional priority (defaults to NORMAL); _drain() sorts the pending queue in
  descending priority order before execution. OperationPriority is exported for
  callers.

- feat(templateManager): add per-template version history. updateTemplate(id,
  content) increments an integer version (starting at 1) and retains all
  previous versions in memory. getTemplate(id, version?) returns a specific
  version or the latest when omitted. getTemplateHistory(id) exposes the full
  ordered history. No persistence layer changes.

- test(broadcaster): add three message-ordering tests — in-order delivery,
  late subscribers miss past messages, mid-sequence unsubscribe stops future
  delivery only.

- test: add test/sponsorshipEvent.test.ts, test/operationQueue.test.ts,
  test/templateManager.test.ts (34 new tests, all passing)
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@agnesadah3-jpg Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kingsman-99
Kingsman-99 merged commit 8d34cb6 into Stellar-split:main Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants