Skip to content

Commit

Permalink
Remove pack's dependency on TokenError (solana-labs#448)
Browse files Browse the repository at this point in the history
* Remove pack's dependency on TokenError

* nudge
  • Loading branch information
jackcmay authored Sep 16, 2020
1 parent 6cd83ce commit 157936c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 38 deletions.
52 changes: 26 additions & 26 deletions token/perf-monitor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions token/perf-monitor/tests/assert_instruction_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ fn run_program(
) -> Result<u64, InstructionError> {
let mut program_account = SolanaAccount::default();
program_account.data = load_program("spl_token");
let loader_id = bpf_loader::id();
let mut invoke_context = MockInvokeContext::default();
let (mut vm, heap_region) = create_vm(
&bpf_loader::id(),
&loader_id,
&program_account.data,
parameter_accounts,
&mut invoke_context,
)
.unwrap();
let mut parameter_bytes = serialize_parameters(
&bpf_loader::id(),
&loader_id,
program_id,
parameter_accounts,
&instruction_data,
Expand All @@ -60,7 +61,7 @@ fn run_program(
vm.execute_program(parameter_bytes.as_mut_slice(), &[], &[heap_region])
.unwrap()
);
deserialize_parameters(&bpf_loader::id(), parameter_accounts, &parameter_bytes).unwrap();
deserialize_parameters(&loader_id, parameter_accounts, &parameter_bytes).unwrap();
Ok(vm.get_total_instruction_count())
}

Expand Down
3 changes: 0 additions & 3 deletions token/program-v3/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ pub enum TokenError {
/// Invalid number of required signers.
#[error("Invalid number of required signers")]
InvalidNumberOfRequiredSigners,
/// State is uninitialized.
#[error("State is unititialized")]
UninitializedState,
/// Instruction does not support native tokens
#[error("Instruction does not support native tokens")]
NativeNotSupported,
Expand Down
3 changes: 1 addition & 2 deletions token/program-v3/src/pack.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! State transition types
use crate::error::TokenError;
use solana_sdk::program_error::ProgramError;

/// Check is a token state is initialized
Expand Down Expand Up @@ -35,7 +34,7 @@ pub trait Pack: Sealed {
if value.is_initialized() {
Ok(value)
} else {
Err(TokenError::UninitializedState.into())
Err(ProgramError::UninitializedAccount)
}
}

Expand Down
7 changes: 3 additions & 4 deletions token/program-v3/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ impl PrintProgramError for TokenError {
TokenError::InvalidNumberOfRequiredSigners => {
info!("Error: Invalid number of required signers")
}
TokenError::UninitializedState => info!("Error: State is uninitialized"),
TokenError::NativeNotSupported => {
info!("Error: Instruction does not support native tokens")
}
Expand Down Expand Up @@ -2511,7 +2510,7 @@ mod tests {

// invalid account
assert_eq!(
Err(TokenError::UninitializedState.into()),
Err(ProgramError::UninitializedAccount),
do_process_instruction(
set_authority(
&program_id,
Expand Down Expand Up @@ -3063,7 +3062,7 @@ mod tests {

// uninitialized destination account
assert_eq!(
Err(TokenError::UninitializedState.into()),
Err(ProgramError::UninitializedAccount),
do_process_instruction(
mint_to(
&program_id,
Expand Down Expand Up @@ -4217,7 +4216,7 @@ mod tests {

// uninitialized
assert_eq!(
Err(TokenError::UninitializedState.into()),
Err(ProgramError::UninitializedAccount),
do_process_instruction(
close_account(&program_id, &account_key, &account3_key, &owner2_key, &[]).unwrap(),
vec![
Expand Down

0 comments on commit 157936c

Please sign in to comment.