Skip to content

Commit 0c10a9f

Browse files
committed
Adjusts tests for write lock demotion.
1 parent 25dc157 commit 0c10a9f

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

programs/sbf/tests/programs.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,8 +1772,18 @@ fn test_program_sbf_invoke_in_same_tx_as_redeployment() {
17721772
],
17731773
);
17741774

1775-
// Redeployment causes programs to be unavailable to both top-level-instructions and CPI instructions
1776-
for invoke_instruction in [invoke_instruction, indirect_invoke_instruction] {
1775+
// Redeployment fails when top-level-instructions invoke the program because of write lock demotion
1776+
// and the program becomes unavailable to CPI instructions
1777+
for (invoke_instruction, expected_error) in [
1778+
(
1779+
invoke_instruction,
1780+
TransactionError::InstructionError(0, InstructionError::InvalidArgument),
1781+
),
1782+
(
1783+
indirect_invoke_instruction,
1784+
TransactionError::InstructionError(2, InstructionError::UnsupportedProgramId),
1785+
),
1786+
] {
17771787
// Call upgradeable program
17781788
let result =
17791789
bank_client.send_and_confirm_instruction(&mint_keypair, invoke_instruction.clone());
@@ -1794,10 +1804,7 @@ fn test_program_sbf_invoke_in_same_tx_as_redeployment() {
17941804
bank.last_blockhash(),
17951805
);
17961806
let (result, _, _, _) = process_transaction_and_record_inner(&bank, tx);
1797-
assert_eq!(
1798-
result.unwrap_err(),
1799-
TransactionError::InstructionError(2, InstructionError::UnsupportedProgramId),
1800-
);
1807+
assert_eq!(result.unwrap_err(), expected_error,);
18011808
}
18021809
}
18031810

@@ -1848,8 +1855,18 @@ fn test_program_sbf_invoke_in_same_tx_as_undeployment() {
18481855
// Prepare undeployment
18491856
let undeployment_instruction = loader_v4::retract(&program_id, &authority_keypair.pubkey());
18501857

1851-
// Undeployment is visible to both top-level-instructions and CPI instructions
1852-
for invoke_instruction in [invoke_instruction, indirect_invoke_instruction] {
1858+
// Undeployment fails when top-level-instructions invoke the program because of write lock demotion
1859+
// and the program becomes unavailable to CPI instructions
1860+
for (invoke_instruction, expected_error) in [
1861+
(
1862+
invoke_instruction,
1863+
TransactionError::InstructionError(0, InstructionError::InvalidArgument),
1864+
),
1865+
(
1866+
indirect_invoke_instruction,
1867+
TransactionError::InstructionError(1, InstructionError::UnsupportedProgramId),
1868+
),
1869+
] {
18531870
// Call upgradeable program
18541871
let result =
18551872
bank_client.send_and_confirm_instruction(&mint_keypair, invoke_instruction.clone());
@@ -1866,10 +1883,7 @@ fn test_program_sbf_invoke_in_same_tx_as_undeployment() {
18661883
bank.last_blockhash(),
18671884
);
18681885
let (result, _, _, _) = process_transaction_and_record_inner(&bank, tx);
1869-
assert_eq!(
1870-
result.unwrap_err(),
1871-
TransactionError::InstructionError(1, InstructionError::UnsupportedProgramId),
1872-
);
1886+
assert_eq!(result.unwrap_err(), expected_error,);
18731887
}
18741888
}
18751889

0 commit comments

Comments
 (0)