@@ -306,6 +306,64 @@ async fn confidential_transfer_configure_token_account() {
306
306
) ;
307
307
}
308
308
309
+ #[ tokio:: test]
310
+ async fn confidential_transfer_fail_approving_account_on_wrong_mint ( ) {
311
+ let authority = Keypair :: new ( ) ;
312
+ let auto_approve_new_accounts = false ;
313
+ let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
314
+ let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
315
+
316
+ let mut context_a = TestContext :: new ( ) . await ;
317
+ context_a
318
+ . init_token_with_mint ( vec ! [
319
+ ExtensionInitializationParams :: ConfidentialTransferMint {
320
+ authority: Some ( authority. pubkey( ) ) ,
321
+ auto_approve_new_accounts,
322
+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
323
+ } ,
324
+ ] )
325
+ . await
326
+ . unwrap ( ) ;
327
+
328
+ let token_a_context = context_a. token_context . unwrap ( ) ;
329
+
330
+ let mut context_b = TestContext {
331
+ context : context_a. context . clone ( ) ,
332
+ token_context : None ,
333
+ } ;
334
+ context_b
335
+ . init_token_with_mint ( vec ! [
336
+ ExtensionInitializationParams :: ConfidentialTransferMint {
337
+ authority: Some ( authority. pubkey( ) ) ,
338
+ auto_approve_new_accounts,
339
+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
340
+ } ,
341
+ ] )
342
+ . await
343
+ . unwrap ( ) ;
344
+ let TokenContext { token, alice, .. } = context_b. token_context . unwrap ( ) ;
345
+ let alice_meta = ConfidentialTokenAccountMeta :: new ( & token, & alice, None , false , false ) . await ;
346
+
347
+ let err = token_a_context
348
+ . token
349
+ . confidential_transfer_approve_account (
350
+ & alice_meta. token_account ,
351
+ & authority. pubkey ( ) ,
352
+ & [ & authority] ,
353
+ )
354
+ . await
355
+ . unwrap_err ( ) ;
356
+ assert_eq ! (
357
+ err,
358
+ TokenClientError :: Client ( Box :: new( TransportError :: TransactionError (
359
+ TransactionError :: InstructionError (
360
+ 0 ,
361
+ InstructionError :: Custom ( TokenError :: MintMismatch as u32 )
362
+ )
363
+ ) ) )
364
+ ) ;
365
+ }
366
+
309
367
#[ tokio:: test]
310
368
async fn confidential_transfer_enable_disable_confidential_credits ( ) {
311
369
let authority = Keypair :: new ( ) ;
0 commit comments