Browse Source

Check error in safety checks test failure (#1571)

Tom Linton 3 years ago
parent
commit
5c5fa7927f

+ 1 - 1
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<Initialize>) -> ProgramResult {
+    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
         Ok(())
     }
 }

+ 1 - 1
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<Initialize>) -> ProgramResult {
+    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
         Ok(())
     }
 }

+ 6 - 6
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