Skip to content

Commit 71dccc5

Browse files
committed
Add LiteSVM integration test for cnft-vault withdraw_cnft
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
1 parent 9f9f470 commit 71dccc5

4 files changed

Lines changed: 463 additions & 16 deletions

File tree

compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_cnft.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use anchor_lang::prelude::*;
2-
use anchor_lang::solana_program::{
3-
instruction::AccountMeta,
4-
program::invoke_signed,
5-
};
2+
use anchor_lang::solana_program::{instruction::AccountMeta, program::invoke_signed};
63

7-
use crate::{build_transfer_instruction, TransferArgs, SPLCompression, MPL_BUBBLEGUM_ID};
4+
use crate::{build_transfer_instruction, SPLCompression, TransferArgs, MPL_BUBBLEGUM_ID};
85

96
#[derive(Accounts)]
107
pub struct Withdraw<'info> {

compression/cnft-vault/anchor/programs/cnft-vault/src/instructions/withdraw_two_cnfts.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use anchor_lang::prelude::*;
2-
use anchor_lang::solana_program::{
3-
instruction::AccountMeta,
4-
program::invoke_signed,
5-
};
2+
use anchor_lang::solana_program::{instruction::AccountMeta, program::invoke_signed};
63

7-
use crate::{build_transfer_instruction, TransferArgs, SPLCompression, MPL_BUBBLEGUM_ID};
4+
use crate::{build_transfer_instruction, SPLCompression, TransferArgs, MPL_BUBBLEGUM_ID};
85

96
#[derive(Accounts)]
107
pub struct WithdrawTwo<'info> {

compression/cnft-vault/anchor/programs/cnft-vault/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::diverging_sub_expression)]
2+
13
use anchor_lang::prelude::*;
24
use anchor_lang::solana_program::instruction::{AccountMeta, Instruction};
35
use borsh::BorshSerialize;
@@ -9,16 +11,14 @@ declare_id!("Fd4iwpPWaCU8BNwGQGtvvrcvG4Tfizq3RgLm8YLBJX6D");
911

1012
/// mpl-bubblegum program ID (BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY)
1113
const MPL_BUBBLEGUM_ID: Pubkey = Pubkey::new_from_array([
12-
0x98, 0x8b, 0x80, 0xeb, 0x79, 0x35, 0x28, 0x69, 0xb2, 0x24, 0x74, 0x5f, 0x59, 0xdd, 0xbf,
13-
0x8a, 0x26, 0x58, 0xca, 0x13, 0xdc, 0x68, 0x81, 0x21, 0x26, 0x35, 0x1c, 0xae, 0x07, 0xc1,
14-
0xa5, 0xa5,
14+
0x98, 0x8b, 0x80, 0xeb, 0x79, 0x35, 0x28, 0x69, 0xb2, 0x24, 0x74, 0x5f, 0x59, 0xdd, 0xbf, 0x8a,
15+
0x26, 0x58, 0xca, 0x13, 0xdc, 0x68, 0x81, 0x21, 0x26, 0x35, 0x1c, 0xae, 0x07, 0xc1, 0xa5, 0xa5,
1516
]);
1617

1718
/// SPL Account Compression program ID (cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK)
1819
const SPL_ACCOUNT_COMPRESSION_ID: Pubkey = Pubkey::new_from_array([
19-
0x09, 0x2a, 0x13, 0xee, 0x95, 0xc4, 0x1c, 0xba, 0x08, 0xa6, 0x7f, 0x5a, 0xc6, 0x7e, 0x8d,
20-
0xf7, 0xe1, 0xda, 0x11, 0x62, 0x5e, 0x1d, 0x64, 0x13, 0x7f, 0x8f, 0x4f, 0x23, 0x83, 0x03,
21-
0x7f, 0x14,
20+
0x09, 0x2a, 0x13, 0xee, 0x95, 0xc4, 0x1c, 0xba, 0x08, 0xa6, 0x7f, 0x5a, 0xc6, 0x7e, 0x8d, 0xf7,
21+
0xe1, 0xda, 0x11, 0x62, 0x5e, 0x1d, 0x64, 0x13, 0x7f, 0x8f, 0x4f, 0x23, 0x83, 0x03, 0x7f, 0x14,
2222
]);
2323

2424
/// Transfer instruction discriminator from mpl-bubblegum
@@ -45,6 +45,7 @@ impl anchor_lang::Id for SPLCompression {
4545

4646
/// Build a mpl-bubblegum Transfer instruction from pubkeys and args.
4747
/// This avoids using mpl-bubblegum's CPI wrapper which requires solana-program 2.x AccountInfo.
48+
#[allow(clippy::too_many_arguments)]
4849
pub fn build_transfer_instruction(
4950
tree_config: Pubkey,
5051
leaf_owner: Pubkey,

0 commit comments

Comments
 (0)