@@ -3279,6 +3279,94 @@ async fn test_confidential_transfer_pending_decryption_after_transfer() {
32793279 }
32803280}
32813281
3282+ #[ tokio:: test]
3283+ async fn confidential_transfer_apply_pending_balance_frozen_account ( ) {
3284+ let authority = Keypair :: new ( ) ;
3285+ let auto_approve_new_accounts = true ;
3286+ let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
3287+ let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
3288+
3289+ let mut context = TestContext :: new ( ) . await ;
3290+ context
3291+ . init_token_with_freezing_mint ( vec ! [
3292+ ExtensionInitializationParams :: ConfidentialTransferMint {
3293+ authority: Some ( authority. pubkey( ) ) ,
3294+ auto_approve_new_accounts,
3295+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
3296+ } ,
3297+ ] )
3298+ . await
3299+ . unwrap ( ) ;
3300+
3301+ let TokenContext {
3302+ token,
3303+ alice,
3304+ mint_authority,
3305+ freeze_authority,
3306+ decimals,
3307+ ..
3308+ } = context. token_context . unwrap ( ) ;
3309+
3310+ let freeze_authority = freeze_authority. unwrap ( ) ;
3311+ let alice_meta = ConfidentialTokenAccountMeta :: new ( & token, & alice, Some ( 2 ) , false , false ) . await ;
3312+
3313+ // Mint tokens to Alice
3314+ token
3315+ . mint_to (
3316+ & alice_meta. token_account ,
3317+ & mint_authority. pubkey ( ) ,
3318+ 1000 ,
3319+ & [ & mint_authority] ,
3320+ )
3321+ . await
3322+ . unwrap ( ) ;
3323+
3324+ // Deposit tokens to create a pending balance
3325+ token
3326+ . confidential_transfer_deposit (
3327+ & alice_meta. token_account ,
3328+ & alice. pubkey ( ) ,
3329+ 1000 ,
3330+ decimals,
3331+ & [ & alice] ,
3332+ )
3333+ . await
3334+ . unwrap ( ) ;
3335+
3336+ // Freeze Alice's account
3337+ token
3338+ . freeze (
3339+ & alice_meta. token_account ,
3340+ & freeze_authority. pubkey ( ) ,
3341+ & [ & freeze_authority] ,
3342+ )
3343+ . await
3344+ . unwrap ( ) ;
3345+
3346+ // Attempt to Apply Pending Balance
3347+ let err = token
3348+ . confidential_transfer_apply_pending_balance (
3349+ & alice_meta. token_account ,
3350+ & alice. pubkey ( ) ,
3351+ None ,
3352+ alice_meta. elgamal_keypair . secret ( ) ,
3353+ & alice_meta. aes_key ,
3354+ & [ & alice] ,
3355+ )
3356+ . await
3357+ . unwrap_err ( ) ;
3358+
3359+ assert_eq ! (
3360+ err,
3361+ TokenClientError :: Client ( Box :: new( TransportError :: TransactionError (
3362+ TransactionError :: InstructionError (
3363+ 0 ,
3364+ InstructionError :: Custom ( TokenError :: AccountFrozen as u32 )
3365+ )
3366+ ) ) )
3367+ ) ;
3368+ }
3369+
32823370#[ cfg( test) ]
32833371mod unit_tests {
32843372
0 commit comments