Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit ab23d6b

Browse files
committed
Augment ct tests with decryptable_available_balance assertions
1 parent 22135e5 commit ab23d6b

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

token/program-2022-test/tests/confidential_transfer.rs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,15 @@ async fn ct_withdraw() {
488488
.await
489489
.unwrap();
490490
assert_eq!(state.base.amount, 21);
491+
let extension = state
492+
.get_extension::<ConfidentialTransferAccount>()
493+
.unwrap();
494+
assert_eq!(
495+
alice_meta
496+
.ae_key
497+
.decrypt(&extension.decryptable_available_balance.try_into().unwrap()),
498+
Some(21),
499+
);
491500

492501
token
493502
.confidential_transfer_withdraw(
@@ -508,6 +517,15 @@ async fn ct_withdraw() {
508517
.await
509518
.unwrap();
510519
assert_eq!(state.base.amount, 42);
520+
let extension = state
521+
.get_extension::<ConfidentialTransferAccount>()
522+
.unwrap();
523+
assert_eq!(
524+
alice_meta
525+
.ae_key
526+
.decrypt(&extension.decryptable_available_balance.try_into().unwrap()),
527+
Some(0),
528+
);
511529

512530
token
513531
.confidential_transfer_empty_account(
@@ -582,6 +600,20 @@ async fn ct_transfer() {
582600
.await
583601
.unwrap();
584602

603+
let state = token
604+
.get_account_info(&alice_meta.token_account)
605+
.await
606+
.unwrap();
607+
let extension = state
608+
.get_extension::<ConfidentialTransferAccount>()
609+
.unwrap();
610+
assert_eq!(
611+
alice_meta
612+
.ae_key
613+
.decrypt(&extension.decryptable_available_balance.try_into().unwrap()),
614+
Some(42),
615+
);
616+
585617
token
586618
.confidential_transfer_transfer(
587619
&alice_meta.token_account,
@@ -595,6 +627,20 @@ async fn ct_transfer() {
595627
.await
596628
.unwrap();
597629

630+
let state = token
631+
.get_account_info(&alice_meta.token_account)
632+
.await
633+
.unwrap();
634+
let extension = state
635+
.get_extension::<ConfidentialTransferAccount>()
636+
.unwrap();
637+
assert_eq!(
638+
alice_meta
639+
.ae_key
640+
.decrypt(&extension.decryptable_available_balance.try_into().unwrap()),
641+
Some(0),
642+
);
643+
598644
token
599645
.confidential_transfer_empty_account(
600646
&alice_meta.token_account,
@@ -618,4 +664,42 @@ async fn ct_transfer() {
618664
TransactionError::InstructionError(1, InstructionError::InvalidAccountData)
619665
)))
620666
);
667+
668+
let state = token
669+
.get_account_info(&bob_meta.token_account)
670+
.await
671+
.unwrap();
672+
let extension = state
673+
.get_extension::<ConfidentialTransferAccount>()
674+
.unwrap();
675+
assert_eq!(
676+
bob_meta
677+
.ae_key
678+
.decrypt(&extension.decryptable_available_balance.try_into().unwrap()),
679+
Some(0),
680+
);
681+
682+
token
683+
.confidential_transfer_apply_pending_balance(
684+
&bob_meta.token_account,
685+
&bob,
686+
1,
687+
bob_meta.ae_key.encrypt(42_u64),
688+
)
689+
.await
690+
.unwrap();
691+
692+
let state = token
693+
.get_account_info(&bob_meta.token_account)
694+
.await
695+
.unwrap();
696+
let extension = state
697+
.get_extension::<ConfidentialTransferAccount>()
698+
.unwrap();
699+
assert_eq!(
700+
bob_meta
701+
.ae_key
702+
.decrypt(&extension.decryptable_available_balance.try_into().unwrap()),
703+
Some(42),
704+
);
621705
}

0 commit comments

Comments
 (0)