Skip to content

test(compression/cnft-burn): fix build + add LiteSVM cNFT-burn test; re-enable in CI#57

Merged
mikemaccana merged 6 commits into
mainfrom
claude/cnft-burn-fix
Jun 5, 2026
Merged

test(compression/cnft-burn): fix build + add LiteSVM cNFT-burn test; re-enable in CI#57
mikemaccana merged 6 commits into
mainfrom
claude/cnft-burn-fix

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

compression/cnft-burn/anchor was excluded ("builds but need to test on localhost") — but it didn't actually build, and had no test. This fixes both and re-enables it.

Build fix

The program was already migrated to Anchor 1.0 (it builds its Bubblegum Burn CPI manually, no mpl-bubblegum/spl-account-compression Rust deps). The only break was a leftover, unused ahash = "=0.8.7" pin, which pulls getrandom 0.2 — that compile_error!s on the SBF target. Removing it → cargo build-sbf succeeds.

Real cNFT-burn test (LiteSVM)

Switched the Anchor test script to cargo test (matching the other re-enabled Anchor examples) and added programs/cnft-burn/tests/test_burn.rs, which exercises the full flow against the real mainnet programs:

  1. Loads the cnft-burn program plus three mainnet fixtures — Bubblegum, SPL account-compression, SPL noop — into LiteSVM (it bundles none of these).
  2. Allocates a ConcurrentMerkleTree<3,8> account and runs Bubblegum create_tree_config.
  3. Mints a cNFT via mint_v1.
  4. Recomputes data_hash/creator_hash exactly as Bubblegum (keccak(keccak(metadata) ++ seller_fee) / hash_creators), builds the index-0 proof from account-compression empty-node hashes, and reads the live root from the tree account.
  5. Calls burn_cnft, asserts success, and asserts a second burn fails (leaf zeroed → stale root).

Fixtures + provenance

The three .so are committed under tests/fixtures/ (same mechanism the repo already uses for mpl_token_metadata.so), with a tests/fixtures/README.md manifest recording each program's ID, source cluster, dump date (2026-06-05) + slot (424532091), and the refresh command.

Note: a crate-level #[allow(clippy::diverging_sub_expression)] was added to lib.rs — a known false positive from the Anchor 1.0 #[program] macro expansion (the root rust.yml already passes -A clippy::diverging_sub_expression for the same reason; this Anchor project is its own workspace).

Verification

Against the CI toolchain (Solana 3.1.x / platform-tools v1.52): cargo build-sbf builds, cargo test passes (test_burn_cnft + discriminator check), cargo fmt --check clean, cargo clippy --tests -D warnings clean. Only the mainnet fixtures (not the built program .so) are committed. Removed compression/cnft-burn/anchor from .github/.ghaignore.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP


Generated by Claude Code

claude added 4 commits June 5, 2026 20:24
The program pinned `ahash = "=0.8.7"` (unused in the source), which pulls
getrandom 0.2 — that `compile_error!`s on the SBF target, so `cargo build-sbf`
/ `anchor build` failed. Drop the pin; the program now builds on the current
toolchain (it was already migrated to Anchor 1.0 with manual Bubblegum CPI).

This does not yet re-enable it in CI: it still needs a cNFT-burn integration
test (load Bubblegum + spl-account-compression + noop fixtures, create a tree,
mint a cNFT, compute the proof, then burn), which is tracked separately.
Re-enable the cnft-burn Anchor example with a Rust LiteSVM test that runs
the full create-tree -> mint -> burn flow against the real mainnet
mpl-bubblegum, spl-account-compression, and spl-noop program binaries.

- Anchor.toml [scripts] test -> cargo test (matches the group/anchor pattern).
- Add litesvm + solana-* 3.x dev-dependencies to the program crate.
- programs/cnft-burn/tests/test_burn.rs:
  - loads cnft_burn.so plus the three committed fixtures into LiteSVM
  - allocates + create_tree_config a depth-3/buffer-8 Bubblegum tree
  - mints one cNFT via mint_v1 (TokenStandard::NonFungible)
  - recomputes data_hash/creator_hash exactly as Bubblegum does
  - builds the empty-node Merkle proof for leaf 0 and reads the live root
    from the on-chain ConcurrentMerkleTree<3,8> account
  - calls burn_cnft, asserts success, and asserts a second burn fails
- Suppress the Anchor #[program] macro's false-positive
  diverging_sub_expression clippy lint at the crate level.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
@mikemaccana mikemaccana merged commit e5b7fd6 into main Jun 5, 2026
18 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