Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: ensure using the latest blockhash to process tx #1720

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 23 additions & 27 deletions programs/zk-token-proof-tests/tests/process_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,15 +1065,14 @@ async fn test_verify_proof_without_context<T, U>(

let client = &mut context.banks_client;
let payer = &context.payer;
let recent_blockhash = context.last_blockhash;

// verify a valid proof (wihtout creating a context account)
let instructions = vec![proof_instruction.encode_verify_proof(None, success_proof_data)];
let transaction = Transaction::new_signed_with_payer(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1083,7 +1082,7 @@ async fn test_verify_proof_without_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand All @@ -1107,7 +1106,7 @@ async fn test_verify_proof_without_context<T, U>(
&instruction.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand All @@ -1127,7 +1126,7 @@ async fn test_verify_proof_without_context<T, U>(
&instruction,
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1138,7 +1137,7 @@ async fn test_verify_proof_without_context<T, U>(
&instruction,
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client
.process_transaction(transaction)
Expand Down Expand Up @@ -1168,7 +1167,6 @@ async fn test_verify_proof_with_context<T, U>(

let client = &mut context.banks_client;
let payer = &context.payer;
let recent_blockhash = context.last_blockhash;

let context_state_account = Keypair::new();
let context_state_authority = Keypair::new();
Expand All @@ -1193,7 +1191,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand All @@ -1220,7 +1218,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand All @@ -1247,7 +1245,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand Down Expand Up @@ -1280,7 +1278,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand Down Expand Up @@ -1308,7 +1306,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1319,7 +1317,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand Down Expand Up @@ -1352,7 +1350,7 @@ async fn test_verify_proof_with_context<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account_and_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();
}
Expand Down Expand Up @@ -1394,7 +1392,6 @@ async fn test_verify_proof_from_account_with_context<T, U>(

let client = &mut context.banks_client;
let payer = &context.payer;
let recent_blockhash = context.last_blockhash;

let context_state_account = Keypair::new();
let context_state_authority = Keypair::new();
Expand Down Expand Up @@ -1423,7 +1420,7 @@ async fn test_verify_proof_from_account_with_context<T, U>(
&instructions,
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand Down Expand Up @@ -1454,7 +1451,7 @@ async fn test_verify_proof_from_account_with_context<T, U>(
&instructions,
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1468,7 +1465,7 @@ async fn test_verify_proof_from_account_with_context<T, U>(
&instructions,
Some(&payer.pubkey()),
&[payer],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand Down Expand Up @@ -1505,7 +1502,7 @@ async fn test_verify_proof_from_account_with_context<T, U>(
&instructions,
Some(&payer.pubkey()),
&[payer, &context_state_account_and_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();
}
Expand All @@ -1526,7 +1523,6 @@ async fn test_close_context_state<T, U>(

let client = &mut context.banks_client;
let payer = &context.payer;
let recent_blockhash = context.last_blockhash;

let context_state_account = Keypair::new();
let context_state_authority = Keypair::new();
Expand All @@ -1553,7 +1549,7 @@ async fn test_close_context_state<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1570,7 +1566,7 @@ async fn test_close_context_state<T, U>(
&vec![instruction].with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &incorrect_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand All @@ -1594,7 +1590,7 @@ async fn test_close_context_state<T, U>(
&vec![instruction.clone()].with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1620,7 +1616,7 @@ async fn test_close_context_state<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account, &context_state_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1646,7 +1642,7 @@ async fn test_close_context_state<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account, &context_state_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();

Expand All @@ -1672,7 +1668,7 @@ async fn test_close_context_state<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account, &context_state_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
let err = client
.process_transaction(transaction)
Expand Down Expand Up @@ -1706,7 +1702,7 @@ async fn test_close_context_state<T, U>(
&instructions.with_max_compute_unit_limit(),
Some(&payer.pubkey()),
&[payer, &context_state_account_and_authority],
recent_blockhash,
client.get_latest_blockhash().await.unwrap(),
);
client.process_transaction(transaction).await.unwrap();
}
Expand Down