Add utility function to help get System error out of ProgramError
This commit is contained in:
@ -447,7 +447,6 @@ mod tests {
|
|||||||
use crate::poh_recorder::WorkingBank;
|
use crate::poh_recorder::WorkingBank;
|
||||||
use solana_runtime::runtime::InstructionError;
|
use solana_runtime::runtime::InstructionError;
|
||||||
use solana_sdk::genesis_block::GenesisBlock;
|
use solana_sdk::genesis_block::GenesisBlock;
|
||||||
use solana_sdk::native_program::ProgramError;
|
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::system_transaction::SystemTransaction;
|
use solana_sdk::system_transaction::SystemTransaction;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
@ -685,7 +684,7 @@ mod tests {
|
|||||||
// ProgramErrors should still be recorded
|
// ProgramErrors should still be recorded
|
||||||
results[0] = Err(BankError::InstructionError(
|
results[0] = Err(BankError::InstructionError(
|
||||||
1,
|
1,
|
||||||
InstructionError::ProgramError(ProgramError::ResultWithNegativeLamports),
|
InstructionError::new_result_with_negative_lamports(),
|
||||||
));
|
));
|
||||||
BankingStage::record_transactions(&transactions, &results, &poh_recorder).unwrap();
|
BankingStage::record_transactions(&transactions, &results, &poh_recorder).unwrap();
|
||||||
let (_, entries) = entry_receiver.recv().unwrap();
|
let (_, entries) = entry_receiver.recv().unwrap();
|
||||||
|
@ -888,7 +888,6 @@ mod tests {
|
|||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use solana_sdk::genesis_block::{GenesisBlock, BOOTSTRAP_LEADER_LAMPORTS};
|
use solana_sdk::genesis_block::{GenesisBlock, BOOTSTRAP_LEADER_LAMPORTS};
|
||||||
use solana_sdk::hash;
|
use solana_sdk::hash;
|
||||||
use solana_sdk::native_program::ProgramError;
|
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::system_instruction::SystemInstruction;
|
use solana_sdk::system_instruction::SystemInstruction;
|
||||||
use solana_sdk::system_program;
|
use solana_sdk::system_program;
|
||||||
@ -1002,7 +1001,7 @@ mod tests {
|
|||||||
bank.get_signature_status(&t1.signatures[0]),
|
bank.get_signature_status(&t1.signatures[0]),
|
||||||
Some(Err(BankError::InstructionError(
|
Some(Err(BankError::InstructionError(
|
||||||
1,
|
1,
|
||||||
InstructionError::ProgramError(ProgramError::ResultWithNegativeLamports)
|
InstructionError::new_result_with_negative_lamports(),
|
||||||
)))
|
)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1050,7 +1049,7 @@ mod tests {
|
|||||||
bank.process_transaction(&tx),
|
bank.process_transaction(&tx),
|
||||||
Err(BankError::InstructionError(
|
Err(BankError::InstructionError(
|
||||||
0,
|
0,
|
||||||
InstructionError::ProgramError(ProgramError::ResultWithNegativeLamports)
|
InstructionError::new_result_with_negative_lamports(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1086,7 +1085,7 @@ mod tests {
|
|||||||
bank.transfer(10_001, &mint_keypair, &pubkey, genesis_block.hash()),
|
bank.transfer(10_001, &mint_keypair, &pubkey, genesis_block.hash()),
|
||||||
Err(BankError::InstructionError(
|
Err(BankError::InstructionError(
|
||||||
0,
|
0,
|
||||||
InstructionError::ProgramError(ProgramError::ResultWithNegativeLamports)
|
InstructionError::new_result_with_negative_lamports(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
assert_eq!(bank.transaction_count(), 1);
|
assert_eq!(bank.transaction_count(), 1);
|
||||||
@ -1187,7 +1186,7 @@ mod tests {
|
|||||||
Ok(()),
|
Ok(()),
|
||||||
Err(BankError::InstructionError(
|
Err(BankError::InstructionError(
|
||||||
1,
|
1,
|
||||||
InstructionError::ProgramError(ProgramError::ResultWithNegativeLamports),
|
InstructionError::new_result_with_negative_lamports(),
|
||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@ pub enum InstructionError {
|
|||||||
ExternalAccountUserdataModified,
|
ExternalAccountUserdataModified,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl InstructionError {
|
||||||
|
pub fn new_result_with_negative_lamports() -> Self {
|
||||||
|
InstructionError::ProgramError(ProgramError::ResultWithNegativeLamports)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Reasons the runtime might have rejected a transaction.
|
/// Reasons the runtime might have rejected a transaction.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum TransactionError {
|
pub enum TransactionError {
|
||||||
|
Reference in New Issue
Block a user