Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
fix loader instruction checker (#18047)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Jun 18, 2021
1 parent 491e445 commit d18e02e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sdk/program/src/bpf_loader_upgradeable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ pub fn upgrade(
}

pub fn is_upgrade_instruction(instruction_data: &[u8]) -> bool {
3 == instruction_data[0]
!instruction_data.is_empty() && 3 == instruction_data[0]
}

pub fn is_set_authority_instruction(instruction_data: &[u8]) -> bool {
4 == instruction_data[0]
!instruction_data.is_empty() && 4 == instruction_data[0]
}

/// Returns the instructions required to set a buffers's authority.
Expand Down Expand Up @@ -331,6 +331,7 @@ mod tests {

#[test]
fn test_is_set_authority_instruction() {
assert!(!is_set_authority_instruction(&[]));
assert_is_instruction(
is_set_authority_instruction,
UpgradeableLoaderInstruction::SetAuthority {},
Expand All @@ -339,6 +340,7 @@ mod tests {

#[test]
fn test_is_upgrade_instruction() {
assert!(!is_upgrade_instruction(&[]));
assert_is_instruction(
is_upgrade_instruction,
UpgradeableLoaderInstruction::Upgrade {},
Expand Down

0 comments on commit d18e02e

Please sign in to comment.