@@ -1617,6 +1617,171 @@ async fn confidential_transfer_transfer() {
16171617 . await ;
16181618}
16191619
1620+ #[ cfg( feature = "zk-ops" ) ]
1621+ #[ tokio:: test]
1622+ async fn pause_confidential_deposit ( ) {
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+ let TokenContext {
1644+ token,
1645+ alice,
1646+ mint_authority,
1647+ decimals,
1648+ ..
1649+ } = context. token_context . unwrap ( ) ;
1650+
1651+ let alice_meta = ConfidentialTokenAccountMeta :: new ( & token, & alice, None , false , false ) . await ;
1652+
1653+ token
1654+ . mint_to (
1655+ & alice_meta. token_account ,
1656+ & mint_authority. pubkey ( ) ,
1657+ 42 ,
1658+ & [ mint_authority] ,
1659+ )
1660+ . await
1661+ . unwrap ( ) ;
1662+
1663+ token
1664+ . pause ( & pausable_authority. pubkey ( ) , & [ & pausable_authority] )
1665+ . await
1666+ . unwrap ( ) ;
1667+
1668+ let error = token
1669+ . confidential_transfer_deposit (
1670+ & alice_meta. token_account ,
1671+ & alice. pubkey ( ) ,
1672+ 42 ,
1673+ decimals,
1674+ & [ alice] ,
1675+ )
1676+ . await
1677+ . unwrap_err ( ) ;
1678+ assert_eq ! (
1679+ error,
1680+ TokenClientError :: Client ( Box :: new( TransportError :: TransactionError (
1681+ TransactionError :: InstructionError (
1682+ 0 ,
1683+ InstructionError :: Custom ( TokenError :: MintPaused as u32 )
1684+ )
1685+ ) ) )
1686+ ) ;
1687+ }
1688+
1689+ #[ cfg( feature = "zk-ops" ) ]
1690+ #[ tokio:: test]
1691+ async fn pause_confidential_withdraw ( ) {
1692+ let authority = Keypair :: new ( ) ;
1693+ let pausable_authority = Keypair :: new ( ) ;
1694+ let auto_approve_new_accounts = true ;
1695+ let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
1696+ let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
1697+
1698+ let mut context = TestContext :: new ( ) . await ;
1699+ context
1700+ . init_token_with_mint ( vec ! [
1701+ ExtensionInitializationParams :: ConfidentialTransferMint {
1702+ authority: Some ( authority. pubkey( ) ) ,
1703+ auto_approve_new_accounts,
1704+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
1705+ } ,
1706+ ExtensionInitializationParams :: PausableConfig {
1707+ authority: pausable_authority. pubkey( ) ,
1708+ } ,
1709+ ] )
1710+ . await
1711+ . unwrap ( ) ;
1712+ let TokenContext {
1713+ token,
1714+ alice,
1715+ mint_authority,
1716+ decimals,
1717+ ..
1718+ } = context. token_context . unwrap ( ) ;
1719+
1720+ let alice_meta = ConfidentialTokenAccountMeta :: new ( & token, & alice, None , false , false ) . await ;
1721+
1722+ token
1723+ . mint_to (
1724+ & alice_meta. token_account ,
1725+ & mint_authority. pubkey ( ) ,
1726+ 42 ,
1727+ & [ mint_authority] ,
1728+ )
1729+ . await
1730+ . unwrap ( ) ;
1731+
1732+ token
1733+ . confidential_transfer_deposit (
1734+ & alice_meta. token_account ,
1735+ & alice. pubkey ( ) ,
1736+ 42 ,
1737+ decimals,
1738+ & [ & alice] ,
1739+ )
1740+ . await
1741+ . unwrap ( ) ;
1742+
1743+ token
1744+ . confidential_transfer_apply_pending_balance (
1745+ & alice_meta. token_account ,
1746+ & alice. pubkey ( ) ,
1747+ None ,
1748+ alice_meta. elgamal_keypair . secret ( ) ,
1749+ & alice_meta. aes_key ,
1750+ & [ & alice] ,
1751+ )
1752+ . await
1753+ . unwrap ( ) ;
1754+
1755+ token
1756+ . pause ( & pausable_authority. pubkey ( ) , & [ & pausable_authority] )
1757+ . await
1758+ . unwrap ( ) ;
1759+
1760+ let error = withdraw_with_option (
1761+ & token,
1762+ & alice_meta. token_account ,
1763+ & alice. pubkey ( ) ,
1764+ 42 ,
1765+ decimals,
1766+ & alice_meta. elgamal_keypair ,
1767+ & alice_meta. aes_key ,
1768+ & [ & alice] ,
1769+ ConfidentialTransferOption :: InstructionData ,
1770+ )
1771+ . await
1772+ . unwrap_err ( ) ;
1773+
1774+ assert_eq ! (
1775+ error,
1776+ TokenClientError :: Client ( Box :: new( TransportError :: TransactionError (
1777+ TransactionError :: InstructionError (
1778+ 0 ,
1779+ InstructionError :: Custom ( TokenError :: MintPaused as u32 )
1780+ )
1781+ ) ) )
1782+ ) ;
1783+ }
1784+
16201785#[ cfg( feature = "zk-ops" ) ]
16211786#[ tokio:: test]
16221787async fn pause_confidential_transfer ( ) {
0 commit comments