@@ -1617,6 +1617,86 @@ async fn confidential_transfer_transfer() {
16171617 . await ;
16181618}
16191619
1620+ #[ cfg( feature = "zk-ops" ) ]
1621+ #[ tokio:: test]
1622+ async fn pause_confidential_transfer ( ) {
1623+ let authority = Keypair :: new ( ) ;
1624+ let pausable_authority = Keypair :: new ( ) ;
1625+ let auto_approve_new_accounts = true ;
1626+ let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
1627+ let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
1628+
1629+ let mut context = TestContext :: new ( ) . await ;
1630+ context
1631+ . init_token_with_mint ( vec ! [
1632+ ExtensionInitializationParams :: ConfidentialTransferMint {
1633+ authority: Some ( authority. pubkey( ) ) ,
1634+ auto_approve_new_accounts,
1635+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
1636+ } ,
1637+ ExtensionInitializationParams :: PausableConfig {
1638+ authority: pausable_authority. pubkey( ) ,
1639+ } ,
1640+ ] )
1641+ . await
1642+ . unwrap ( ) ;
1643+
1644+ let TokenContext {
1645+ token,
1646+ alice,
1647+ bob,
1648+ mint_authority,
1649+ decimals,
1650+ ..
1651+ } = context. token_context . unwrap ( ) ;
1652+
1653+ let alice_meta = ConfidentialTokenAccountMeta :: new_with_tokens (
1654+ & token,
1655+ & alice,
1656+ None ,
1657+ false ,
1658+ false ,
1659+ & mint_authority,
1660+ 42 ,
1661+ decimals,
1662+ )
1663+ . await ;
1664+
1665+ let bob_meta = ConfidentialTokenAccountMeta :: new ( & token, & bob, Some ( 2 ) , false , false ) . await ;
1666+
1667+ // pause it
1668+ token
1669+ . pause ( & pausable_authority. pubkey ( ) , & [ & pausable_authority] )
1670+ . await
1671+ . unwrap ( ) ;
1672+ let error = confidential_transfer_with_option (
1673+ & token,
1674+ & alice_meta. token_account ,
1675+ & bob_meta. token_account ,
1676+ & alice. pubkey ( ) ,
1677+ 10 ,
1678+ & alice_meta. elgamal_keypair ,
1679+ & alice_meta. aes_key ,
1680+ bob_meta. elgamal_keypair . pubkey ( ) ,
1681+ Some ( auditor_elgamal_keypair. pubkey ( ) ) ,
1682+ None ,
1683+ & [ & alice] ,
1684+ ConfidentialTransferOption :: InstructionData ,
1685+ )
1686+ . await
1687+ . unwrap_err ( ) ;
1688+
1689+ assert_eq ! (
1690+ error,
1691+ TokenClientError :: Client ( Box :: new( TransportError :: TransactionError (
1692+ TransactionError :: InstructionError (
1693+ 0 ,
1694+ InstructionError :: Custom ( TokenError :: MintPaused as u32 )
1695+ )
1696+ ) ) )
1697+ ) ;
1698+ }
1699+
16201700#[ cfg( feature = "zk-ops" ) ]
16211701async fn confidential_transfer_transfer_with_option ( option : ConfidentialTransferOption ) {
16221702 let authority = Keypair :: new ( ) ;
@@ -2328,6 +2408,107 @@ async fn confidential_transfer_transfer_with_fee() {
23282408 . await ;
23292409}
23302410
2411+ #[ cfg( feature = "zk-ops" ) ]
2412+ #[ tokio:: test]
2413+ async fn pause_confidential_transfer_with_fee ( ) {
2414+ let transfer_fee_authority = Keypair :: new ( ) ;
2415+ let withdraw_withheld_authority = Keypair :: new ( ) ;
2416+
2417+ let pausable_authority = Keypair :: new ( ) ;
2418+ let confidential_transfer_authority = Keypair :: new ( ) ;
2419+ let auto_approve_new_accounts = true ;
2420+ let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
2421+ let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
2422+
2423+ let confidential_transfer_fee_authority = Keypair :: new ( ) ;
2424+ let withdraw_withheld_authority_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
2425+ let withdraw_withheld_authority_elgamal_pubkey =
2426+ ( * withdraw_withheld_authority_elgamal_keypair. pubkey ( ) ) . into ( ) ;
2427+
2428+ let mut context = TestContext :: new ( ) . await ;
2429+ context
2430+ . init_token_with_mint ( vec ! [
2431+ ExtensionInitializationParams :: TransferFeeConfig {
2432+ transfer_fee_config_authority: Some ( transfer_fee_authority. pubkey( ) ) ,
2433+ withdraw_withheld_authority: Some ( withdraw_withheld_authority. pubkey( ) ) ,
2434+ transfer_fee_basis_points: TEST_FEE_BASIS_POINTS ,
2435+ maximum_fee: TEST_MAXIMUM_FEE ,
2436+ } ,
2437+ ExtensionInitializationParams :: ConfidentialTransferMint {
2438+ authority: Some ( confidential_transfer_authority. pubkey( ) ) ,
2439+ auto_approve_new_accounts,
2440+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
2441+ } ,
2442+ ExtensionInitializationParams :: ConfidentialTransferFeeConfig {
2443+ authority: Some ( confidential_transfer_fee_authority. pubkey( ) ) ,
2444+ withdraw_withheld_authority_elgamal_pubkey,
2445+ } ,
2446+ ExtensionInitializationParams :: PausableConfig {
2447+ authority: pausable_authority. pubkey( ) ,
2448+ } ,
2449+ ] )
2450+ . await
2451+ . unwrap ( ) ;
2452+
2453+ let TokenContext {
2454+ token,
2455+ alice,
2456+ bob,
2457+ mint_authority,
2458+ decimals,
2459+ ..
2460+ } = context. token_context . unwrap ( ) ;
2461+
2462+ let alice_meta = ConfidentialTokenAccountMeta :: new_with_tokens (
2463+ & token,
2464+ & alice,
2465+ None ,
2466+ false ,
2467+ true ,
2468+ & mint_authority,
2469+ 100 ,
2470+ decimals,
2471+ )
2472+ . await ;
2473+
2474+ let bob_meta = ConfidentialTokenAccountMeta :: new ( & token, & bob, None , false , true ) . await ;
2475+
2476+ token
2477+ . pause ( & pausable_authority. pubkey ( ) , & [ & pausable_authority] )
2478+ . await
2479+ . unwrap ( ) ;
2480+
2481+ let error = confidential_transfer_with_fee_with_option (
2482+ & token,
2483+ & alice_meta. token_account ,
2484+ & bob_meta. token_account ,
2485+ & alice. pubkey ( ) ,
2486+ 10 ,
2487+ & alice_meta. elgamal_keypair ,
2488+ & alice_meta. aes_key ,
2489+ bob_meta. elgamal_keypair . pubkey ( ) ,
2490+ Some ( auditor_elgamal_keypair. pubkey ( ) ) ,
2491+ withdraw_withheld_authority_elgamal_keypair. pubkey ( ) ,
2492+ TEST_FEE_BASIS_POINTS ,
2493+ TEST_MAXIMUM_FEE ,
2494+ None ,
2495+ & [ & alice] ,
2496+ ConfidentialTransferOption :: InstructionData ,
2497+ )
2498+ . await
2499+ . unwrap_err ( ) ;
2500+
2501+ assert_eq ! (
2502+ error,
2503+ TokenClientError :: Client ( Box :: new( TransportError :: TransactionError (
2504+ TransactionError :: InstructionError (
2505+ 0 ,
2506+ InstructionError :: Custom ( TokenError :: MintPaused as u32 )
2507+ )
2508+ ) ) )
2509+ ) ;
2510+ }
2511+
23312512#[ cfg( feature = "zk-ops" ) ]
23322513async fn confidential_transfer_transfer_with_fee_with_option ( option : ConfidentialTransferOption ) {
23332514 let transfer_fee_authority = Keypair :: new ( ) ;
0 commit comments