Remove circular dep between InstructionError and SystemError (#11427)
This commit is contained in:
parent
14dcaaee6c
commit
3fdd8ffdf0
|
@ -1032,6 +1032,7 @@ mod tests {
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
instruction::InstructionError,
|
instruction::InstructionError,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
|
system_instruction::SystemError,
|
||||||
system_transaction,
|
system_transaction,
|
||||||
transaction::TransactionError,
|
transaction::TransactionError,
|
||||||
};
|
};
|
||||||
|
@ -1397,7 +1398,7 @@ mod tests {
|
||||||
results[0] = (
|
results[0] = (
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
1,
|
1,
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
SystemError::ResultWithNegativeLamports.into(),
|
||||||
)),
|
)),
|
||||||
Some(HashAgeKind::Extant),
|
Some(HashAgeKind::Extant),
|
||||||
);
|
);
|
||||||
|
|
|
@ -981,9 +981,9 @@ pub mod tests {
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
instruction::InstructionError,
|
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
|
system_instruction::SystemError,
|
||||||
system_transaction,
|
system_transaction,
|
||||||
transaction::{Transaction, TransactionError},
|
transaction::{Transaction, TransactionError},
|
||||||
};
|
};
|
||||||
|
@ -2401,7 +2401,7 @@ pub mod tests {
|
||||||
bank.transfer(10_001, &mint_keypair, &pubkey),
|
bank.transfer(10_001, &mint_keypair, &pubkey),
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
0,
|
0,
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
SystemError::ResultWithNegativeLamports.into(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -3149,7 +3149,8 @@ mod tests {
|
||||||
poh_config::PohConfig,
|
poh_config::PohConfig,
|
||||||
rent::Rent,
|
rent::Rent,
|
||||||
signature::{Keypair, Signer},
|
signature::{Keypair, Signer},
|
||||||
system_instruction, system_program,
|
system_instruction::{self, SystemError},
|
||||||
|
system_program,
|
||||||
sysvar::{fees::Fees, rewards::Rewards},
|
sysvar::{fees::Fees, rewards::Rewards},
|
||||||
timing::duration_as_s,
|
timing::duration_as_s,
|
||||||
};
|
};
|
||||||
|
@ -5060,10 +5061,7 @@ mod tests {
|
||||||
let tx = Transaction::new(&[&mint_keypair], message, genesis_config.hash());
|
let tx = Transaction::new(&[&mint_keypair], message, genesis_config.hash());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.process_transaction(&tx).unwrap_err(),
|
bank.process_transaction(&tx).unwrap_err(),
|
||||||
TransactionError::InstructionError(
|
TransactionError::InstructionError(1, SystemError::ResultWithNegativeLamports.into())
|
||||||
1,
|
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 1);
|
assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 1);
|
||||||
assert_eq!(bank.get_balance(&key1), 0);
|
assert_eq!(bank.get_balance(&key1), 0);
|
||||||
|
@ -5105,7 +5103,7 @@ mod tests {
|
||||||
bank.process_transaction(&tx),
|
bank.process_transaction(&tx),
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
0,
|
0,
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
SystemError::ResultWithNegativeLamports.into(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5141,7 +5139,7 @@ mod tests {
|
||||||
bank.transfer(10_001, &mint_keypair, &pubkey),
|
bank.transfer(10_001, &mint_keypair, &pubkey),
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
0,
|
0,
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
SystemError::ResultWithNegativeLamports.into(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
assert_eq!(bank.transaction_count(), 1);
|
assert_eq!(bank.transaction_count(), 1);
|
||||||
|
@ -5410,7 +5408,7 @@ mod tests {
|
||||||
(
|
(
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
1,
|
1,
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
SystemError::ResultWithNegativeLamports.into(),
|
||||||
)),
|
)),
|
||||||
Some(HashAgeKind::Extant),
|
Some(HashAgeKind::Extant),
|
||||||
),
|
),
|
||||||
|
@ -6525,7 +6523,7 @@ mod tests {
|
||||||
bank.transfer(10_001, &mint_keypair, &Pubkey::new_rand()),
|
bank.transfer(10_001, &mint_keypair, &Pubkey::new_rand()),
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
0,
|
0,
|
||||||
InstructionError::new_result_with_negative_lamports(),
|
SystemError::ResultWithNegativeLamports.into(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7171,7 +7169,7 @@ mod tests {
|
||||||
bank.process_transaction(&durable_tx),
|
bank.process_transaction(&durable_tx),
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
1,
|
1,
|
||||||
system_instruction::SystemError::ResultWithNegativeLamports.into()
|
system_instruction::SystemError::ResultWithNegativeLamports.into(),
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
/* Check fee charged and nonce has advanced */
|
/* Check fee charged and nonce has advanced */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Defines a composable Instruction type and a memory-efficient CompiledInstruction.
|
//! Defines a composable Instruction type and a memory-efficient CompiledInstruction.
|
||||||
|
|
||||||
use crate::sanitize::Sanitize;
|
use crate::sanitize::Sanitize;
|
||||||
use crate::{pubkey::Pubkey, short_vec, system_instruction::SystemError};
|
use crate::{pubkey::Pubkey, short_vec};
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -161,12 +161,6 @@ pub enum InstructionError {
|
||||||
InvalidSeeds,
|
InvalidSeeds,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InstructionError {
|
|
||||||
pub fn new_result_with_negative_lamports() -> Self {
|
|
||||||
SystemError::ResultWithNegativeLamports.into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct Instruction {
|
pub struct Instruction {
|
||||||
/// Pubkey of the instruction processor that executes this instruction
|
/// Pubkey of the instruction processor that executes this instruction
|
||||||
|
|
Loading…
Reference in New Issue