From 93f1c75a52a2938869e868129107b552dd04d6ce Mon Sep 17 00:00:00 2001 From: blockiosaurus Date: Mon, 6 Feb 2023 09:50:06 -0500 Subject: [PATCH] Adding helpful error prints for the nonzero data check. --- program/src/state/rules.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/program/src/state/rules.rs b/program/src/state/rules.rs index 187bbd72..cb5b6931 100644 --- a/program/src/state/rules.rs +++ b/program/src/state/rules.rs @@ -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 { @@ -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) { @@ -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()); }