From 5c5fa7927f515e8a755bbbcf8b72bf7e1d7e3871 Mon Sep 17 00:00:00 2001 From: Tom Linton Date: Wed, 9 Mar 2022 10:00:25 +1300 Subject: [PATCH] Check error in safety checks test failure (#1571) --- tests/safety-checks/programs/account-info/src/lib.rs | 2 +- .../programs/unchecked-account/src/lib.rs | 2 +- tests/safety-checks/test.sh | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/safety-checks/programs/account-info/src/lib.rs b/tests/safety-checks/programs/account-info/src/lib.rs index 670e1073..74d8f121 100644 --- a/tests/safety-checks/programs/account-info/src/lib.rs +++ b/tests/safety-checks/programs/account-info/src/lib.rs @@ -5,7 +5,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); #[program] pub mod account_info { use super::*; - pub fn initialize(ctx: Context) -> ProgramResult { + pub fn initialize(ctx: Context) -> Result<()> { Ok(()) } } diff --git a/tests/safety-checks/programs/unchecked-account/src/lib.rs b/tests/safety-checks/programs/unchecked-account/src/lib.rs index 4d86648d..d9f59cf8 100644 --- a/tests/safety-checks/programs/unchecked-account/src/lib.rs +++ b/tests/safety-checks/programs/unchecked-account/src/lib.rs @@ -5,7 +5,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); #[program] pub mod unchecked_account { use super::*; - pub fn initialize(ctx: Context) -> ProgramResult { + pub fn initialize(ctx: Context) -> Result<()> { Ok(()) } } diff --git a/tests/safety-checks/test.sh b/tests/safety-checks/test.sh index d9d4cec5..935c4a59 100755 --- a/tests/safety-checks/test.sh +++ b/tests/safety-checks/test.sh @@ -6,9 +6,9 @@ echo "Building programs" # Build the UncheckedAccount variant. # pushd programs/unchecked-account/ -anchor build -if [ $? -eq 0 ]; then - echo "Error: expected failure" +output=$(anchor build 2>&1 > /dev/null) +if ! [[ $output =~ "Struct field \"unchecked\" is unsafe" ]]; then + echo "Error: expected /// CHECK error" exit 1 fi popd @@ -17,9 +17,9 @@ popd # Build the AccountInfo variant. # pushd programs/account-info/ -anchor build -if [ $? -eq 0 ]; then - echo "Error: expected failure" +output=$(anchor build 2>&1 > /dev/null) +if ! [[ $output =~ "Struct field \"unchecked\" is unsafe" ]]; then + echo "Error: expected /// CHECK error" exit 1 fi popd