Skip to content

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Jan 6, 2026

Summary by CodeRabbit

  • Tests

    • Added integration tests that validate the complete workflow for compressing restricted Token-2022 mints through the forester, including account tracking and indexer retrieval.
  • Chores

    • Updated development dependencies.

✏️ Tip: You can customize this high-level summary in your review settings.

@ananas-block ananas-block marked this pull request as draft January 6, 2026 19:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This PR introduces a new integration test validating end-to-end compression of restricted Token-2022 mints. A dev dependency on anchor-spl is added to support test infrastructure.

Changes

Cohort / File(s) Summary
Dependency addition
forester/Cargo.toml
Added anchor-spl = { workspace = true } to dev-dependencies to support test compilation and execution.
Integration test suite
forester/tests/test_restricted_mint_compression.rs
New comprehensive test file containing: ForesterContext struct for encapsulating test state; register_forester() helper that sets up governance, forester registration, and epoch phases; test_restricted_mint_compression() that validates the full pipeline—restricted mint creation with PermanentDelegate extension, compressible token account setup, forester registration, compression execution, on-chain state verification, and indexer query validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sergeytimoshin

Poem

🌱 A restricted mint takes flight,
Through forester's careful hand,
Compression glows in test-light,
Indexer confirms the command! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'chore: add tlv parsing issue reproducer' does not match the actual changes, which add a comprehensive integration test for restricted mint compression with forester registration and indexer validation. Update the title to accurately reflect the main change, such as 'feat: add integration test for restricted mint compression with forester' or 'test: add comprehensive compression test with token-2022 restricted mint'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/chore-photon-with-tlv-tx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI Agents
In @forester/tests/test_restricted_mint_compression.rs:
- Around line 439-449: The assertions use redundant Pubkey::from() conversions
on compressed_account.token_data.mint and .owner which are already Pubkey types;
remove the Pubkey::from(...) wrappers and compare the Pubkey values directly
(e.g., assert_eq!(compressed_account.token_data.mint, mint.pubkey(), ...) and
assert_eq!(compressed_account.token_data.owner, owner_keypair.pubkey(), ...)) to
eliminate the lint failures.
- Around line 46-48: Extract the duplicated async helper function
register_forester (used in test_restricted_mint_compression.rs and
test_compressible_ctoken.rs) into a shared test utilities module (e.g.,
tests/common/mod.rs or tests/util.rs), move its definition there, export it
(pub) and update both test files to import and call the shared register_forester
instead of their local copies; ensure any type bounds (R: Rpc) and supporting
imports are also moved or re-exported so the tests compile without further
changes.
- Around line 32-35: The test imports the deprecated
solana_sdk::system_instruction; replace that import with the dedicated interface
crate by importing system_instruction from solana_system_interface (e.g., change
the use statement referencing system_instruction to use
solana_system_interface::system_instruction) and add solana-system-interface = {
workspace = true } to [dev-dependencies] in Cargo.toml so tests compile against
the new interface crate.
- Around line 377-397: The compressor task is being aborted which swallows
errors; replace the final compressor_handle.abort() with awaiting the task
result and handling outcomes from the JoinHandle returned by tokio::spawn: await
compressor_handle, inspect Ok(result) and call result.expect or propagate its
Err from Compressor::compress_batch, treat a cancelled JoinHandle as the timeout
case, and panic/log if the JoinHandle reports a panic so test failures surface
(refer to Compressor::new, compressor_handle, and compress_batch to locate the
code).
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89d3cef and b3a5e15.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock and included by none
📒 Files selected for processing (2)
  • forester/Cargo.toml
  • forester/tests/test_restricted_mint_compression.rs
🧰 Additional context used
📓 Path-based instructions (3)
forester/**/*.rs

📄 CodeRabbit inference engine (forester/README.md)

forester/**/*.rs: When running tests locally, the test will automatically spawn a local validator and start a local prover service using predefined URLs (localhost:8899 for RPC, localhost:8784 for indexer)
Automatically skip minting tokens, executing transactions, and root verification for disabled test types

Files:

  • forester/tests/test_restricted_mint_compression.rs
**/*test*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*test*.rs: When testing account state, use borsh deserialization with a single assert_eq against an expected reference account
Use type-safe assertions with actual struct fields instead of magic byte offsets when testing account data
Test assertions should deserialize account data using borsh before validation
Extract runtime-specific values from deserialized accounts before building expected reference state

Files:

  • forester/tests/test_restricted_mint_compression.rs
forester/**/*test*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Run forester end-to-end tests with 'TEST_MODE=local cargo test --package forester e2e_test -- --nocapture'

Files:

  • forester/tests/test_restricted_mint_compression.rs
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run compressed token core tests using `cargo test-sbf -p compressed-token-test --test ctoken`, `--test v1`, `--test mint`, and `--test transfer2`
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run E2E extended tests after building the small compressed token program using `pnpm --filter lightprotocol/programs run build-compressed-token-small` followed by `cargo test-sbf -p e2e-test -- --test test_10_all`
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:52.872Z
Learning: Applies to sdk-tests/sdk-anchor-test/package.json : Maintain TypeScript integration test scripts in package.json with commands for "build" and "test-ts" targeting Anchor SDK tests
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/README.md:0-0
Timestamp: 2025-11-24T17:54:38.537Z
Learning: Implement compressed token program interfaces for third-party token creation and usage on Solana using ZK Compression
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:20.702Z
Learning: Compressed token accounts must support compression to spl tokens and decompression back, with spl tokens serving as decompressed representations
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/anchor/README.md:0-0
Timestamp: 2025-11-24T17:54:33.614Z
Learning: Implement the Compressed Token Program interface for creating and using compressed tokens on Solana with ZK Compression
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run account-compression tests using `cargo test-sbf -p account-compression-test` to test core account compression program (Merkle tree management)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:20.702Z
Learning: The program is a compressed token implementation similar to spl-token that supports both compressed token accounts (TokenData) and decompressed ctoken solana accounts (CompressedToken) with compatible account layouts
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run Light system program compression tests using `cargo test-sbf -p system-test -- test_with_compression` and `cargo test-sbf -p system-test --test test_re_init_cpi_account` to test compressed account operations
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: js/compressed-token/README.md:0-0
Timestamp: 2025-11-24T17:53:57.540Z
Learning: This is the JavaScript SDK for interacting with the Compressed Token program on Solana
📚 Learning: 2025-12-07T03:17:28.803Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/Cargo.toml : Use path references in Cargo.toml dependencies pointing to `/Users/ananas/dev/light-protocol2/sdk-libs/` for light-ctoken-sdk, light-ctoken-types, light-sdk, light-sdk-types, and light-program-test

Applied to files:

  • forester/Cargo.toml
📚 Learning: 2026-01-05T19:53:20.702Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:20.702Z
Learning: Applies to programs/compressed-token/program/program-libs/ctoken-interface/src/state/ctoken/**/*.rs : CToken account layout must match SPL token account layout, with a custom extension named Compressible for rent management

Applied to files:

  • forester/Cargo.toml
  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2026-01-05T19:53:36.706Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:36.706Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/compressed_token/**/*.md : Anchor program instructions for compressed token accounts must be documented separately in instructions/compressed_token/ directory and should include operations like Freeze and Thaw

Applied to files:

  • forester/Cargo.toml
📚 Learning: 2026-01-05T19:53:36.706Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:36.706Z
Learning: Program instructions should be organized into logical categories: Account Creation, Transfer Operations, Mint Management, Token Account Operations, and Anchor Program Instructions (compressed token)

Applied to files:

  • forester/Cargo.toml
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run compressed token core tests using `cargo test-sbf -p compressed-token-test --test ctoken`, `--test v1`, `--test mint`, and `--test transfer2`

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run account-compression tests using `cargo test-sbf -p account-compression-test` to test core account compression program (Merkle tree management)

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run Light system program compression tests using `cargo test-sbf -p system-test -- test_with_compression` and `cargo test-sbf -p system-test --test test_re_init_cpi_account` to test compressed account operations

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-12-19T12:31:15.409Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: forester/README.md:0-0
Timestamp: 2025-12-19T12:31:15.409Z
Learning: Applies to forester/**/*.rs : Automatically skip minting tokens, executing transactions, and root verification for disabled test types

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2026-01-05T19:53:20.702Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:20.702Z
Learning: Applies to programs/compressed-token/program/program-libs/ctoken-interface/src/state/mint/**/*.rs : Compressed mint accounts (cmints) must support exactly one extension: TokenMetadata

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/decompress_context.rs : Decompression trait implementation (`DecompressContext`) with account accessors, PDA/token separation logic, and token processing delegation should be in `decompress_context.rs`

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2026-01-05T19:53:20.702Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:20.702Z
Learning: Applies to programs/compressed-token/program/src/**/*.rs : Rent top-up calculations for compressible accounts must use utilities from `src/shared/compressible_top_up.rs`

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-12-19T12:31:15.409Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: forester/README.md:0-0
Timestamp: 2025-12-19T12:31:15.409Z
Learning: Use `forester status --full` for comprehensive status checks including compressed token program tests

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-12-06T00:49:57.458Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:57.458Z
Learning: Applies to sdk-tests/sdk-token-test/**/*test.rs : Tests should use light-ctoken-sdk functions from sdk-libs/compressed-token-sdk for testing ctoken instructions

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2026-01-05T19:54:29.700Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-05T19:54:29.700Z
Learning: Applies to forester/**/*test*.rs : Run forester end-to-end tests with 'TEST_MODE=local cargo test --package forester e2e_test -- --nocapture'

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Account closure must distribute lamports according to: Solana rent exemption → returned to user, completed epoch rent → rent recipient, partial epoch rent → user, compression incentive → forester node

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2026-01-05T19:53:20.702Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2026-01-05T19:53:20.702Z
Learning: Applies to programs/compressed-token/program/src/transfer2/compression/**/*.rs : Rent authority can only compress accounts when `is_compressible()` returns true

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : CompressibleConfig account structure must support serialization via Anchor, Pinocchio, and Borsh formats for Light Registry program integration

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
📚 Learning: 2025-12-07T03:17:28.803Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Use compressible token account extensions that allow accounts to be compressed back into compressed state with rent payment mechanisms

Applied to files:

  • forester/tests/test_restricted_mint_compression.rs
🪛 GitHub Actions: forester-tests
forester/tests/test_restricted_mint_compression.rs

[error] 33-33: use of deprecated module solana_sdk::system_instruction. Use solana_system_interface crate instead

🪛 GitHub Actions: lint
forester/tests/test_restricted_mint_compression.rs

[error] 33-33: use of deprecated module solana_sdk::system_instruction: Use solana_system_interface crate instead

🪛 GitHub Check: Forester e2e test
forester/tests/test_restricted_mint_compression.rs

[failure] 33-33:
use of deprecated module solana_sdk::system_instruction: Use solana_system_interface crate instead

🪛 GitHub Check: lint
forester/tests/test_restricted_mint_compression.rs

[failure] 446-446:
useless conversion to the same type: solana_sdk::entrypoint::__Pubkey


[failure] 441-441:
useless conversion to the same type: solana_sdk::entrypoint::__Pubkey


[failure] 33-33:
use of deprecated module solana_sdk::system_instruction: Use solana_system_interface crate instead

⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: stateless-js-v2
🔇 Additional comments (7)
forester/Cargo.toml (1)

70-70: LGTM!

Clean addition of anchor-spl as a dev-dependency for the new Token-2022 integration test. Using workspace = true keeps version management consistent with the rest of the project.

forester/tests/test_restricted_mint_compression.rs (6)

39-44: LGTM!

Clean encapsulation of forester registration context. The struct nicely bundles the keypair, RPC pool, and epoch state needed for compression testing.


170-177: Using placeholder PDAs — verify these aren't needed downstream.

The epoch_pda and forester_epoch_pda are set to Pubkey::default(), and merkle_trees is empty. This works for this test since these fields aren't used by the Compressor, but could cause subtle bugs if the test evolves to use them.


201-212: Test queries indexer (line 417-431) but starts validator with enable_indexer: false.

The validator is configured with enable_indexer: false, yet the test later calls get_compressed_token_accounts_by_owner on the indexer. Given the docstring mentions this is a reproducer for a Photon indexer parsing issue, I suspect the external indexer is expected to be running separately, but this could cause the test to fail unexpectedly if the indexer isn't available.

Consider adding a comment clarifying the indexer setup or adding a skip condition when no external indexer is present.


258-301: LGTM!

Correct Token-2022 mint setup: account creation → extension initialization → mint initialization. The order matters here since extensions must be initialized before the mint, and you've got it right.


318-353: LGTM!

Clean setup of the compressible token account with num_prepaid_epochs: 0 for immediate compression eligibility. The verification that the tracker captured the account is thorough, checking pubkey, mint, and owner.


457-468: LGTM!

Clean shutdown sequence: signal broadcast followed by awaiting both subscriber tasks. This ensures resources are properly cleaned up before the test exits.

Comment on lines +32 to +35
use solana_sdk::{
pubkey::Pubkey, signature::Keypair, signer::Signer, system_instruction,
transaction::Transaction,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use solana_system_interface instead of deprecated solana_sdk::system_instruction.

The pipeline is failing because solana_sdk::system_instruction is deprecated. The Solana ecosystem has moved these types to dedicated interface crates.

🔎 Proposed fix
 use solana_sdk::{
-    pubkey::Pubkey, signature::Keypair, signer::Signer, system_instruction,
-    transaction::Transaction,
+    pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction,
 };
+use solana_system_interface::instruction as system_instruction;

You'll also need to add solana-system-interface to [dev-dependencies] in Cargo.toml:

solana-system-interface = { workspace = true }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use solana_sdk::{
pubkey::Pubkey, signature::Keypair, signer::Signer, system_instruction,
transaction::Transaction,
};
use solana_sdk::{
pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction,
};
use solana_system_interface::instruction as system_instruction;
🧰 Tools
🪛 GitHub Actions: forester-tests

[error] 33-33: use of deprecated module solana_sdk::system_instruction. Use solana_system_interface crate instead

🪛 GitHub Actions: lint

[error] 33-33: use of deprecated module solana_sdk::system_instruction: Use solana_system_interface crate instead

🪛 GitHub Check: Forester e2e test

[failure] 33-33:
use of deprecated module solana_sdk::system_instruction: Use solana_system_interface crate instead

🪛 GitHub Check: lint

[failure] 33-33:
use of deprecated module solana_sdk::system_instruction: Use solana_system_interface crate instead

🤖 Prompt for AI Agents
In @forester/tests/test_restricted_mint_compression.rs around lines 32 - 35, The
test imports the deprecated solana_sdk::system_instruction; replace that import
with the dedicated interface crate by importing system_instruction from
solana_system_interface (e.g., change the use statement referencing
system_instruction to use solana_system_interface::system_instruction) and add
solana-system-interface = { workspace = true } to [dev-dependencies] in
Cargo.toml so tests compile against the new interface crate.

Comment on lines +46 to +48
/// Register a forester for epoch 0 and wait for registration phase to complete
/// (Reused from test_compressible_ctoken.rs)
async fn register_forester<R: Rpc>(
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider extracting this helper to a shared test utility module.

The comment notes this is "reused from test_compressible_ctoken.rs". Having duplicate registration logic across test files creates maintenance burden — when the registration flow changes, multiple files need updates. Consider extracting to a shared module (e.g., tests/common/mod.rs or a test utilities crate).

🤖 Prompt for AI Agents
In @forester/tests/test_restricted_mint_compression.rs around lines 46 - 48,
Extract the duplicated async helper function register_forester (used in
test_restricted_mint_compression.rs and test_compressible_ctoken.rs) into a
shared test utilities module (e.g., tests/common/mod.rs or tests/util.rs), move
its definition there, export it (pub) and update both test files to import and
call the shared register_forester instead of their local copies; ensure any type
bounds (R: Rpc) and supporting imports are also moved or re-exported so the
tests compile without further changes.

Comment on lines +377 to +397
let compressor = Compressor::new(ctx.rpc_pool.clone(), tracker.clone(), ctx.forester_keypair);
let compressor_handle = tokio::spawn(async move {
compressor
.compress_batch(&ready_accounts, registered_forester_pda)
.await
});
sleep(Duration::from_millis(2000)).await;

// 9. Wait for account to be closed on-chain
let start = tokio::time::Instant::now();
let timeout = Duration::from_secs(30);
let mut account_closed = false;
while start.elapsed() < timeout {
let account = rpc_from_pool.get_account(ctoken_pubkey).await.unwrap();
if account.is_none() || account.as_ref().map(|a| a.lamports) == Some(0) {
account_closed = true;
break;
}
sleep(Duration::from_millis(500)).await;
}
compressor_handle.abort();
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider awaiting the compressor task result instead of aborting.

Aborting the task with abort() silently discards any errors or panics that occurred. For a reproducer test, it would be valuable to see if the compressor encountered issues:

// Instead of abort, check the result
match compressor_handle.await {
    Ok(result) => result.expect("Compression failed"),
    Err(e) if e.is_cancelled() => { /* timeout, ok */ }
    Err(e) => panic!("Compressor task panicked: {}", e),
}

That said, for a quick reproducer this is fine as-is.

🤖 Prompt for AI Agents
In @forester/tests/test_restricted_mint_compression.rs around lines 377 - 397,
The compressor task is being aborted which swallows errors; replace the final
compressor_handle.abort() with awaiting the task result and handling outcomes
from the JoinHandle returned by tokio::spawn: await compressor_handle, inspect
Ok(result) and call result.expect or propagate its Err from
Compressor::compress_batch, treat a cancelled JoinHandle as the timeout case,
and panic/log if the JoinHandle reports a panic so test failures surface (refer
to Compressor::new, compressor_handle, and compress_batch to locate the code).

Comment on lines +439 to +449
let compressed_account = &compressed_accounts[0];
assert_eq!(
Pubkey::from(compressed_account.token_data.mint),
mint.pubkey(),
"Compressed account mint should match"
);
assert_eq!(
Pubkey::from(compressed_account.token_data.owner),
owner_keypair.pubkey(),
"Compressed account owner should match"
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove redundant Pubkey::from() conversions — these are causing lint failures.

The compressed_account.token_data.mint and .owner are already Pubkey types, so the conversion is unnecessary.

🔎 Proposed fix
     let compressed_account = &compressed_accounts[0];
     assert_eq!(
-        Pubkey::from(compressed_account.token_data.mint),
+        compressed_account.token_data.mint,
         mint.pubkey(),
         "Compressed account mint should match"
     );
     assert_eq!(
-        Pubkey::from(compressed_account.token_data.owner),
+        compressed_account.token_data.owner,
         owner_keypair.pubkey(),
         "Compressed account owner should match"
     );
🧰 Tools
🪛 GitHub Check: lint

[failure] 446-446:
useless conversion to the same type: solana_sdk::entrypoint::__Pubkey


[failure] 441-441:
useless conversion to the same type: solana_sdk::entrypoint::__Pubkey

🤖 Prompt for AI Agents
In @forester/tests/test_restricted_mint_compression.rs around lines 439 - 449,
The assertions use redundant Pubkey::from() conversions on
compressed_account.token_data.mint and .owner which are already Pubkey types;
remove the Pubkey::from(...) wrappers and compare the Pubkey values directly
(e.g., assert_eq!(compressed_account.token_data.mint, mint.pubkey(), ...) and
assert_eq!(compressed_account.token_data.owner, owner_keypair.pubkey(), ...)) to
eliminate the lint failures.

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