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

Commit edac3c5

Browse files
Disable confidential transfer tests (#3786)
* disable confidential transfer tests * featurize additional parts of the code
1 parent abc77af commit edac3c5

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

token/program-2022-test/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ version = "0.0.1"
99

1010
[features]
1111
test-sbf = []
12+
zk-ops = []
1213

1314
[build-dependencies]
1415
walkdir = "2"

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use {
66
program_test::{TestContext, TokenContext},
77
solana_program_test::tokio,
88
solana_sdk::{
9-
epoch_info::EpochInfo, instruction::InstructionError, pubkey::Pubkey, signature::Signer,
10-
signer::keypair::Keypair, transaction::TransactionError, transport::TransportError,
9+
instruction::InstructionError, pubkey::Pubkey, signature::Signer, signer::keypair::Keypair,
10+
transaction::TransactionError, transport::TransportError,
1111
},
1212
spl_token_2022::{
1313
error::TokenError,
@@ -19,7 +19,7 @@ use {
1919
},
2020
solana_zk_token_sdk::{
2121
encryption::{auth_encryption::*, elgamal::*},
22-
zk_token_elgamal::{self, pod::Zeroable},
22+
zk_token_elgamal::pod::Zeroable,
2323
},
2424
},
2525
spl_token_client::{
@@ -29,10 +29,16 @@ use {
2929
std::convert::TryInto,
3030
};
3131

32+
#[cfg(feature = "zk-ops")]
33+
use {solana_sdk::epoch_info::EpochInfo, spl_token_2022::solana_zk_token_sdk::zk_token_elgamal};
34+
35+
#[cfg(feature = "zk-ops")]
3236
const TEST_MAXIMUM_FEE: u64 = 100;
37+
#[cfg(feature = "zk-ops")]
3338
const TEST_FEE_BASIS_POINTS: u16 = 250;
3439
const TEST_MAXIMUM_PENDING_BALANCE_CREDIT_COUNTER: u64 = 2;
3540

41+
#[cfg(feature = "zk-ops")]
3642
fn test_epoch_info() -> EpochInfo {
3743
EpochInfo {
3844
epoch: 0,
@@ -49,6 +55,7 @@ struct ConfidentialTransferMintWithKeypairs {
4955
ct_mint_authority: Keypair,
5056
#[allow(dead_code)]
5157
ct_mint_transfer_auditor_encryption_keypair: ElGamalKeypair,
58+
#[allow(dead_code)]
5259
ct_mint_withdraw_withheld_authority_encryption_keypair: ElGamalKeypair,
5360
}
5461

@@ -123,6 +130,7 @@ impl ConfidentialTokenAccountMeta {
123130
}
124131
}
125132

133+
#[cfg(feature = "zk-ops")]
126134
async fn new_with_required_memo_transfers<T>(token: &Token<T>, owner: &Keypair) -> Self
127135
where
128136
T: SendTransaction,
@@ -165,6 +173,7 @@ impl ConfidentialTokenAccountMeta {
165173
}
166174
}
167175

176+
#[cfg(feature = "zk-ops")]
168177
async fn with_tokens<T>(
169178
token: &Token<T>,
170179
owner: &Keypair,
@@ -199,6 +208,7 @@ impl ConfidentialTokenAccountMeta {
199208
meta
200209
}
201210

211+
#[cfg(feature = "zk-ops")]
202212
async fn check_balances<T>(&self, token: &Token<T>, expected: ConfidentialTokenAccountBalances)
203213
where
204214
T: SendTransaction,
@@ -238,13 +248,15 @@ impl ConfidentialTokenAccountMeta {
238248
}
239249
}
240250

251+
#[cfg(feature = "zk-ops")]
241252
struct ConfidentialTokenAccountBalances {
242253
pending_balance_lo: u64,
243254
pending_balance_hi: u64,
244255
available_balance: u64,
245256
decryptable_available_balance: u64,
246257
}
247258

259+
#[cfg(feature = "zk-ops")]
248260
async fn check_withheld_amount_in_mint<T>(
249261
token: &Token<T>,
250262
withdraw_withheld_authority_encryption_keypair: &ElGamalKeypair,
@@ -468,6 +480,7 @@ async fn ct_new_account_is_empty() {
468480
.unwrap();
469481
}
470482

483+
#[cfg(feature = "zk-ops")]
471484
#[tokio::test]
472485
async fn ct_deposit() {
473486
let ConfidentialTransferMintWithKeypairs { ct_mint, .. } =
@@ -591,6 +604,7 @@ async fn ct_deposit() {
591604
assert_eq!(extension.actual_pending_balance_credit_counter, 2.into());
592605
}
593606

607+
#[cfg(feature = "zk-ops")]
594608
#[tokio::test]
595609
async fn ct_withdraw() {
596610
let ConfidentialTransferMintWithKeypairs { ct_mint, .. } =
@@ -693,6 +707,7 @@ async fn ct_withdraw() {
693707
.unwrap();
694708
}
695709

710+
#[cfg(feature = "zk-ops")]
696711
#[tokio::test]
697712
async fn ct_transfer() {
698713
let ConfidentialTransferMintWithKeypairs { ct_mint, .. } =
@@ -920,6 +935,7 @@ async fn ct_transfer() {
920935
.await;
921936
}
922937

938+
#[cfg(feature = "zk-ops")]
923939
#[tokio::test]
924940
async fn ct_transfer_with_fee() {
925941
let ConfidentialTransferMintWithKeypairs { ct_mint, .. } =
@@ -1123,6 +1139,7 @@ async fn ct_transfer_with_fee() {
11231139
.await;
11241140
}
11251141

1142+
#[cfg(feature = "zk-ops")]
11261143
#[tokio::test]
11271144
async fn ct_withdraw_withheld_tokens_from_mint() {
11281145
let ConfidentialTransferMintWithKeypairs {
@@ -1277,6 +1294,7 @@ async fn ct_withdraw_withheld_tokens_from_mint() {
12771294
.await;
12781295
}
12791296

1297+
#[cfg(feature = "zk-ops")]
12801298
#[tokio::test]
12811299
async fn ct_withdraw_withheld_tokens_from_accounts() {
12821300
let ConfidentialTransferMintWithKeypairs {
@@ -1396,6 +1414,7 @@ async fn ct_withdraw_withheld_tokens_from_accounts() {
13961414
.await;
13971415
}
13981416

1417+
#[cfg(feature = "zk-ops")]
13991418
#[tokio::test]
14001419
async fn ct_transfer_memo() {
14011420
let ConfidentialTransferMintWithKeypairs { ct_mint, .. } =
@@ -1496,6 +1515,7 @@ async fn ct_transfer_memo() {
14961515
.await;
14971516
}
14981517

1518+
#[cfg(feature = "zk-ops")]
14991519
#[tokio::test]
15001520
async fn ct_transfer_with_fee_memo() {
15011521
let ConfidentialTransferMintWithKeypairs { ct_mint, .. } =

token/program-2022/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ no-entrypoint = []
1313
test-sbf = []
1414
serde-traits = ["serde", "serde_with"]
1515
# Remove these features once the underlying syscalls are released on all networks
16-
default = ["zk-ops"]
16+
default = []
1717
zk-ops = []
1818

1919
[dependencies]

token/program-2022/src/extension/confidential_transfer/processor.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use {
44
error::TokenError,
55
extension::{
66
confidential_transfer::{instruction::*, *},
7-
memo_transfer::{check_previous_sibling_instruction_is_memo, memo_required},
8-
non_transferable::NonTransferable,
97
StateWithExtensions, StateWithExtensionsMut,
108
},
119
instruction::{decode_instruction_data, decode_instruction_type},
@@ -26,7 +24,11 @@ use {
2624
// Remove feature once zk ops syscalls are enabled on all networks
2725
#[cfg(feature = "zk-ops")]
2826
use {
29-
crate::extension::transfer_fee::TransferFeeConfig,
27+
crate::extension::{
28+
memo_transfer::{check_previous_sibling_instruction_is_memo, memo_required},
29+
non_transferable::NonTransferable,
30+
transfer_fee::TransferFeeConfig,
31+
},
3032
solana_program::{clock::Clock, sysvar::Sysvar},
3133
solana_zk_token_sdk::zk_token_elgamal::ops,
3234
};
@@ -46,13 +48,15 @@ fn decode_proof_instruction<T: Pod>(
4648
}
4749

4850
/// Checks if a confidential extension is configured to send funds
51+
#[cfg(feature = "zk-ops")]
4952
fn check_source_confidential_account(
5053
source_confidential_transfer_account: &ConfidentialTransferAccount,
5154
) -> ProgramResult {
5255
source_confidential_transfer_account.approved()
5356
}
5457

5558
/// Checks if a confidential extension is configured to receive funds
59+
#[cfg(feature = "zk-ops")]
5660
fn check_destination_confidential_account(
5761
destination_confidential_transfer_account: &ConfidentialTransferAccount,
5862
) -> ProgramResult {

0 commit comments

Comments
 (0)