Skip to content

Commit

Permalink
Adding helpful error prints for the nonzero data check.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Feb 6, 2023
1 parent 7e42bcd commit 93f1c75
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions program/src/state/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ impl Rule {
};

if is_zeroed(&data) {
// Print helpful errors.
if data.len() == 0 {
msg!("Account data is empty");
} else {
msg!("Account data is zeroed");
}

// Account must have nonzero data to count as program-owned.
return (false, self.to_error());
} else if *account.owner == *program {
Expand Down Expand Up @@ -434,6 +441,13 @@ impl Rule {
};

if is_zeroed(&data) {
// Print helpful errors.
if data.len() == 0 {
msg!("Account data is empty");
} else {
msg!("Account data is zeroed");
}

// Account must have nonzero data to count as program-owned.
(false, self.to_error())
} else if programs.iter().any(|program| *account.owner == *program) {
Expand Down Expand Up @@ -469,6 +483,13 @@ impl Rule {

// Account must have nonzero data to count as program-owned.
if is_zeroed(&data) {
// Print helpful errors.
if data.len() == 0 {
msg!("Account data is empty");
} else {
msg!("Account data is zeroed");
}

return (false, self.to_error());
}

Expand Down

0 comments on commit 93f1c75

Please sign in to comment.