1
- #![ cfg( feature = "test-sbf" ) ]
1
+ // #![cfg(feature = "test-sbf")]
2
2
3
3
mod program_test;
4
4
use {
19
19
} ,
20
20
spl_token_client:: {
21
21
client:: ProgramBanksClientProcessTransaction ,
22
- token:: { ExtensionInitializationParams , ProofAccount , Token } ,
22
+ token:: { ExtensionInitializationParams , ProofAccount , ProofAccountWithCiphertext , Token } ,
23
23
} ,
24
24
spl_token_confidential_transfer_proof_generation:: {
25
25
burn:: burn_split_proof_data, mint:: mint_split_proof_data,
@@ -36,21 +36,27 @@ async fn test_confidential_mint() {
36
36
let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
37
37
let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
38
38
let supply_aes_key = AeKey :: new_rand ( ) ;
39
+ let mint_account = Keypair :: new ( ) ;
39
40
40
41
let mut context = TestContext :: new ( ) . await ;
41
42
context
42
- . init_token_with_mint ( vec ! [
43
- ExtensionInitializationParams :: ConfidentialTransferMint {
44
- authority: Some ( authority. pubkey( ) ) ,
45
- auto_approve_new_accounts: true ,
46
- auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
47
- } ,
48
- ExtensionInitializationParams :: ConfidentialMintBurnMint {
49
- authority: authority. pubkey( ) ,
50
- confidential_supply_pubkey: Some ( auditor_elgamal_pubkey) ,
51
- decryptable_supply: Some ( supply_aes_key. encrypt( 0 ) . into( ) ) ,
52
- } ,
53
- ] )
43
+ . init_token_with_mint_keypair_and_freeze_authority_and_mint_authority (
44
+ mint_account,
45
+ vec ! [
46
+ ExtensionInitializationParams :: ConfidentialTransferMint {
47
+ authority: Some ( authority. pubkey( ) ) ,
48
+ auto_approve_new_accounts: true ,
49
+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
50
+ } ,
51
+ ExtensionInitializationParams :: ConfidentialMintBurnMint {
52
+ confidential_supply_pubkey: auditor_elgamal_pubkey,
53
+ decryptable_supply: supply_aes_key. encrypt( 0 ) . into( ) ,
54
+ } ,
55
+ ] ,
56
+ None ,
57
+ // hacky but we have to clone somehow
58
+ Keypair :: from_bytes ( & authority. to_bytes ( ) ) . unwrap ( ) ,
59
+ )
54
60
. await
55
61
. unwrap ( ) ;
56
62
@@ -121,21 +127,26 @@ async fn test_confidential_burn() {
121
127
let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
122
128
let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
123
129
let supply_aes_key = AeKey :: new_rand ( ) ;
130
+ let mint_account = Keypair :: new ( ) ;
124
131
125
132
let mut context = TestContext :: new ( ) . await ;
126
133
context
127
- . init_token_with_mint ( vec ! [
128
- ExtensionInitializationParams :: ConfidentialTransferMint {
129
- authority: Some ( authority. pubkey( ) ) ,
130
- auto_approve_new_accounts: true ,
131
- auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
132
- } ,
133
- ExtensionInitializationParams :: ConfidentialMintBurnMint {
134
- authority: authority. pubkey( ) ,
135
- confidential_supply_pubkey: Some ( auditor_elgamal_pubkey) ,
136
- decryptable_supply: Some ( supply_aes_key. encrypt( 0 ) . into( ) ) ,
137
- } ,
138
- ] )
134
+ . init_token_with_mint_keypair_and_freeze_authority_and_mint_authority (
135
+ mint_account,
136
+ vec ! [
137
+ ExtensionInitializationParams :: ConfidentialTransferMint {
138
+ authority: Some ( authority. pubkey( ) ) ,
139
+ auto_approve_new_accounts: true ,
140
+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
141
+ } ,
142
+ ExtensionInitializationParams :: ConfidentialMintBurnMint {
143
+ confidential_supply_pubkey: auditor_elgamal_pubkey,
144
+ decryptable_supply: supply_aes_key. encrypt( 0 ) . into( ) ,
145
+ } ,
146
+ ] ,
147
+ None ,
148
+ Keypair :: from_bytes ( & authority. to_bytes ( ) ) . unwrap ( ) ,
149
+ )
139
150
. await
140
151
. unwrap ( ) ;
141
152
@@ -227,7 +238,9 @@ async fn test_confidential_burn() {
227
238
. confidential_transfer_create_context_state_account (
228
239
& ciphertext_validity_proof_context_pubkey,
229
240
& context_state_auth_pubkey,
230
- & proof_data. ciphertext_validity_proof_data ,
241
+ & proof_data
242
+ . ciphertext_validity_proof_data_with_ciphertext
243
+ . proof_data ,
231
244
false ,
232
245
ciphertext_validity_proof_signer,
233
246
)
@@ -247,6 +260,15 @@ async fn test_confidential_burn() {
247
260
let equality_proof_location = ProofAccount :: ContextAccount ( equality_proof_context_pubkey) ;
248
261
let ciphertext_validity_proof_location =
249
262
ProofAccount :: ContextAccount ( ciphertext_validity_proof_context_pubkey) ;
263
+ let ciphertext_validity_proof_location = ProofAccountWithCiphertext {
264
+ proof_account : ciphertext_validity_proof_location,
265
+ ciphertext_lo : proof_data
266
+ . ciphertext_validity_proof_data_with_ciphertext
267
+ . ciphertext_lo ,
268
+ ciphertext_hi : proof_data
269
+ . ciphertext_validity_proof_data_with_ciphertext
270
+ . ciphertext_hi ,
271
+ } ;
250
272
let range_proof_location = ProofAccount :: ContextAccount ( range_proof_context_pubkey) ;
251
273
252
274
// do the burn
@@ -324,21 +346,26 @@ async fn test_rotate_supply_elgamal() {
324
346
let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
325
347
let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
326
348
let supply_aes_key = AeKey :: new_rand ( ) ;
349
+ let mint_account = Keypair :: new ( ) ;
327
350
328
351
let mut context = TestContext :: new ( ) . await ;
329
352
context
330
- . init_token_with_mint ( vec ! [
331
- ExtensionInitializationParams :: ConfidentialTransferMint {
332
- authority: Some ( authority. pubkey( ) ) ,
333
- auto_approve_new_accounts: true ,
334
- auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
335
- } ,
336
- ExtensionInitializationParams :: ConfidentialMintBurnMint {
337
- authority: authority. pubkey( ) ,
338
- confidential_supply_pubkey: Some ( auditor_elgamal_pubkey) ,
339
- decryptable_supply: Some ( supply_aes_key. encrypt( 0 ) . into( ) ) ,
340
- } ,
341
- ] )
353
+ . init_token_with_mint_keypair_and_freeze_authority_and_mint_authority (
354
+ mint_account,
355
+ vec ! [
356
+ ExtensionInitializationParams :: ConfidentialTransferMint {
357
+ authority: Some ( authority. pubkey( ) ) ,
358
+ auto_approve_new_accounts: true ,
359
+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
360
+ } ,
361
+ ExtensionInitializationParams :: ConfidentialMintBurnMint {
362
+ confidential_supply_pubkey: auditor_elgamal_pubkey,
363
+ decryptable_supply: supply_aes_key. encrypt( 0 ) . into( ) ,
364
+ } ,
365
+ ] ,
366
+ None ,
367
+ Keypair :: from_bytes ( & authority. to_bytes ( ) ) . unwrap ( ) ,
368
+ )
342
369
. await
343
370
. unwrap ( ) ;
344
371
@@ -400,11 +427,7 @@ async fn test_rotate_supply_elgamal() {
400
427
401
428
assert_eq ! (
402
429
mint_burn_extension. supply_elgamal_pubkey,
403
- Some ( Into :: <PodElGamalPubkey >:: into(
404
- * new_supply_elgamal_keypair. pubkey( ) ,
405
- ) )
406
- . try_into( )
407
- . unwrap( ) ,
430
+ Into :: <PodElGamalPubkey >:: into( * new_supply_elgamal_keypair. pubkey( ) , ) ,
408
431
) ;
409
432
}
410
433
@@ -465,7 +488,9 @@ async fn mint_tokens(
465
488
. confidential_transfer_create_context_state_account (
466
489
& ciphertext_validity_proof_context_pubkey,
467
490
& context_state_auth. pubkey ( ) ,
468
- & proof_data. ciphertext_validity_proof_data ,
491
+ & proof_data
492
+ . ciphertext_validity_proof_data_with_ciphertext
493
+ . proof_data ,
469
494
false ,
470
495
ciphertext_validity_proof_signer,
471
496
)
@@ -485,8 +510,21 @@ async fn mint_tokens(
485
510
let equality_proof_location = ProofAccount :: ContextAccount ( equality_proof_context_pubkey) ;
486
511
let ciphertext_validity_proof_location =
487
512
ProofAccount :: ContextAccount ( ciphertext_validity_proof_context_pubkey) ;
513
+ let ciphertext_validity_proof_location = ProofAccountWithCiphertext {
514
+ proof_account : ciphertext_validity_proof_location,
515
+ ciphertext_lo : proof_data
516
+ . ciphertext_validity_proof_data_with_ciphertext
517
+ . ciphertext_lo ,
518
+ ciphertext_hi : proof_data
519
+ . ciphertext_validity_proof_data_with_ciphertext
520
+ . ciphertext_hi ,
521
+ } ;
488
522
let range_proof_location = ProofAccount :: ContextAccount ( range_proof_context_pubkey) ;
489
523
524
+ println ! (
525
+ "TOKEN: {}, ata: {token_account}, auth: {authority}" ,
526
+ token. get_address( )
527
+ ) ;
490
528
token
491
529
. confidential_mint (
492
530
token_account,
0 commit comments