Skip to content

test: add TransferFee test for transfer_recurring_delegation#154

Merged
dev-jodee merged 1 commit into
solana-foundation:mainfrom
gamandeepsingh:test/recurring-transfer-fee-token-2022
Jun 4, 2026
Merged

test: add TransferFee test for transfer_recurring_delegation#154
dev-jodee merged 1 commit into
solana-foundation:mainfrom
gamandeepsingh:test/recurring-transfer-fee-token-2022

Conversation

@gamandeepsingh
Copy link
Copy Markdown

@gamandeepsingh gamandeepsingh commented Jun 4, 2026

Summary

Closes #153

Adds test_recurring_transfer_token_2022_transfer_fee to
tests/integration-tests/src/test_transfer_recurring_delegation.rs,
closing a parity gap with the fixed-delegation test suite.

What the test verifies:

  • Transfer succeeds against a Token-2022 mint with TransferFeeConfig (1% fee)
  • Alice's ATA loses the gross amount (10,000,000)
  • Bob's ATA receives the net amount (9,900,000) — fee withheld from receiver
  • amount_pulled_in_period records the gross amount (10,000,000), not the net

The third assertion is the important one: it documents that the per-period
cap enforces limits on what is pulled from the delegator, independent
of what the delegatee actually receives after fees.

Test plan

  • cargo test -p tests-subscriptions test_transfer_recurring_delegation — all 22 tests pass

@gamandeepsingh gamandeepsingh requested a review from dev-jodee as a code owner June 4, 2026 11:16
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

@gamandeepsingh is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 4, 2026

Greptile Summary

This PR adds a single integration test, test_recurring_transfer_token_2022_transfer_fee, that closes a parity gap between the fixed-delegation and recurring-delegation test suites. The new test mirrors the existing test_fixed_transfer_token_2022_transfer_fee exactly, exercising the same Token-2022 mint setup (1% fee, 100 basis points, 1,000,000 max fee cap) through the recurring code path.

  • Mint is initialised with TransferFeeConfig (100 bps, max fee 1,000,000) and the test correctly asserts Alice loses the gross 10,000,000, Bob receives the net 9,900,000, and amount_pulled_in_period captures the gross amount — consistent with the rest of the suite and the existing fixed-delegation equivalent.
  • All arithmetic is correct: 1% of 10,000,000 = 100,000 fee, well under the 1,000,000 maximum, giving 9,900,000 net to Bob.

Confidence Score: 5/5

Safe to merge — adds a single, self-contained integration test with no production code changes.

The test is arithmetically correct, mirrors the already-passing fixed-delegation counterpart exactly, and all three assertions (Alice's debit, Bob's net credit, gross amount tracked in delegation state) are consistent with Token-2022 transfer-fee mechanics and the rest of the test suite.

No files require special attention.

Important Files Changed

Filename Overview
tests/integration-tests/src/test_transfer_recurring_delegation.rs Adds test_recurring_transfer_token_2022_transfer_fee — a direct parity test for the existing fixed-delegation TransferFee test, verifying gross-debit, net-credit, and amount_pulled_in_period semantics; all assertions are arithmetically correct and the test setup is consistent with the rest of the suite.

Sequence Diagram

sequenceDiagram
    participant Alice as Alice (delegator)
    participant Program as Subscriptions Program
    participant Mint as Token-2022 Mint (1% fee)
    participant Bob as Bob (delegatee)

    Alice->>Program: initialize_subscription_authority
    Alice->>Program: create_recurring_delegation(50_000_000/period)
    Bob->>Program: "transfer_recurring_delegation(amount=10_000_000)"
    Program->>Mint: transfer_checked_with_fee(10_000_000)
    Mint-->>Alice: debit 10_000_000 (gross)
    Mint-->>Bob: credit 9_900_000 (net, 100_000 withheld)
    Program->>Program: "record amount_pulled_in_period = 10_000_000 (gross)"
Loading

Reviews (1): Last reviewed commit: "test: add recurring transfer fee test fo..." | Re-trigger Greptile

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
solana-subscriptions-program Ready Ready Preview, Comment Jun 4, 2026 2:17pm

Request Review

@dev-jodee
Copy link
Copy Markdown
Collaborator

Thanks for the work :) signed commits are required, for this time it's fine but next contributions we'll need signed commits

@dev-jodee dev-jodee merged commit edd56fb into solana-foundation:main Jun 4, 2026
14 of 15 checks passed
@gamandeepsingh
Copy link
Copy Markdown
Author

Thanks for the review and for merging it! understood regarding signed commits. I'll make sure future contributions use signed commits and follow the repository guidelines

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.

test: add TransferFee coverage for transfer_recurring_delegation (parity with fixed delegation)

2 participants