Skip to content

test(compression): fix build + add LiteSVM tests for cutils & cnft-vault; re-enable in CI#58

Merged
mikemaccana merged 6 commits into
mainfrom
claude/compression-cutils-vault
Jun 5, 2026
Merged

test(compression): fix build + add LiteSVM tests for cutils & cnft-vault; re-enable in CI#58
mikemaccana merged 6 commits into
mainfrom
claude/compression-cutils-vault

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

Re-enables the other two excluded compression examples, the same way as cnft-burn (#57). Both were already migrated to Anchor 1.0 with manual Bubblegum CPI; both were broken only by a leftover, unused ahash = "=0.8.7" pin (pulls getrandom 0.2, which compile_error!s on the SBF target), and both had no Rust test.

Changes (per example)

  • Remove the ahash pin → builds on the current toolchain.
  • Add [dev-dependencies] (litesvm 0.11 + solana-* 3.x + solana-keccak-hasher) and switch the Anchor test script to cargo test (matching the other re-enabled Anchor examples).
  • Commit the mainnet program fixtures under tests/fixtures/ with a provenance README (program IDs, source cluster, dump date 2026-06-05 + slot, refresh command).
  • Add a LiteSVM Rust test, and drop the example from .github/.ghaignore.

compression/cutils

cutils mints a cNFT via Bubblegum MintToCollectionV1 and verifies a leaf via account-compression verify_leaf. The test (test_cutils_mint_and_verify): builds a real Token-Metadata sized collection NFT (so the collection check passes), creates a Bubblegum tree, calls the program's mint, recomputes data_hash/creator_hash (with collection.verified = true), checks the rebuilt root equals the on-chain root, then calls verify and asserts success — plus a tampered-data_hash negative case. Because it uses MintToCollectionV1, this example also needs the mpl_token_metadata.so fixture (in addition to bubblegum/account-compression/noop).

compression/cnft-vault

cnft-vault holds cNFTs in a vault PDA and withdraws them via Bubblegum Transfer signed by the PDA. The test (test_withdraw_cnft): mints a cNFT owned by the vault PDA ([b"cNFT-vault"]), then calls withdraw_cnft to transfer it to a recipient, asserts success, and asserts a stale-root replay fails. (withdraw_two_cnfts left untested — would need two trees/proofs; noted.)

Fixtures / notes

Same mechanism the repo already uses for mpl_token_metadata.so. Each example carries its own fixture copies (Anchor projects are independent workspaces). A crate-level #[allow(clippy::diverging_sub_expression)] was added to each lib.rs (the sanctioned Anchor #[program] macro false positive; root rust.yml already passes -A clippy::diverging_sub_expression).

Verification (CI toolchain, Solana 3.1.x / platform-tools v1.52)

Both: cargo build-sbf builds, cargo test passes (cutils 2 tests, cnft-vault 1), cargo fmt --check clean, cargo clippy --tests -D warnings clean. Only mainnet fixtures (not the built program .so) are committed.

After this + #57 merge, the only remaining .ghaignore entries are tools/shank-and-solita/native (legacy Solita toolchain) and tokens/token-extensions/{metadata,nft-meta-data-pointer}/anchor (dep bumps).

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP


Generated by Claude Code

claude added 6 commits June 5, 2026 21:25
Exercises the cutils program end to end under LiteSVM:
- Builds a real Token-Metadata sized-collection NFT (mint + metadata +
  master edition) so Bubblegum MintToCollectionV1's collection check passes.
- Creates a ConcurrentMerkleTree<3,8> via account-compression alloc +
  Bubblegum create_tree_config.
- Calls the cutils `mint` instruction to mint one cNFT into the tree/collection.
- Recomputes data_hash/creator_hash exactly as Bubblegum stores the leaf
  (collection verified=true after MintToCollectionV1), builds the empty-node
  proof for leaf 0, reads the live root, and calls the cutils `verify`
  instruction, asserting success and that a tampered data_hash fails.

Adds the mpl_token_metadata mainnet fixture (required by MintToCollectionV1)
and two clippy allows in the program source (diverging_sub_expression false
positive from Anchor's #[program] macro, and vec_init_then_push on the
intentional MintToCollectionV1 account-meta builder).

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
Adds programs/cnft-vault/tests/test_vault.rs, a LiteSVM test that:
- loads the built cnft-vault program plus the three mainnet fixtures
  (mpl-bubblegum, spl-account-compression, spl-noop)
- creates a Bubblegum ConcurrentMerkleTree<3,8> and mints a cNFT whose
  leaf_owner is the vault PDA (seeds [b"cNFT-vault"])
- recomputes data_hash/creator_hash, builds the index-0 empty-node proof,
  reads the live root
- calls withdraw_cnft (CPIs Bubblegum Transfer, vault PDA signs via
  invoke_signed) to move the cNFT to a recipient, asserting success and
  that a replay with the now-stale root fails

Also: add #![allow(clippy::diverging_sub_expression)] (accepted Anchor
#[program] false positive) and #[allow(clippy::too_many_arguments)] on
build_transfer_instruction, plus rustfmt cleanup, so fmt/clippy are clean.

withdraw_two_cnfts is left untested (would need two trees/leaves/proofs).

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
@mikemaccana mikemaccana force-pushed the claude/compression-cutils-vault branch from d8841ae to 9f9b5e7 Compare June 5, 2026 21:26
@mikemaccana mikemaccana merged commit d22b3e1 into main Jun 5, 2026
17 checks passed
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