armaniferrante 4 年之前
父節點
當前提交
e35e6ff96d
共有 2 個文件被更改,包括 21 次插入2 次删除
  1. 19 0
      lang/src/fuzzing.rs
  2. 2 2
      lang/syn/src/codegen/program.rs

+ 19 - 0
lang/src/fuzzing.rs

@@ -45,6 +45,7 @@ impl Environment {
             current_program: None,
             current_program: None,
             accounts: AccountStore::new(),
             accounts: AccountStore::new(),
         };
         };
+        env.register(Box::new(SystemProgram));
         env.register(Box::new(SplToken));
         env.register(Box::new(SplToken));
         env
         env
     }
     }
@@ -236,3 +237,21 @@ impl Program for SplToken {
         spl_token::ID
         spl_token::ID
     }
     }
 }
 }
+
+#[derive(Debug)]
+struct SystemProgram;
+
+impl Program for SystemProgram {
+    fn entry(
+        &self,
+        program_id: &Pubkey,
+        accounts: &[AccountInfo],
+        ix_data: &[u8],
+    ) -> ProgramResult {
+        // todo
+        Ok(())
+    }
+    fn id(&self) -> Pubkey {
+        system_program::ID
+    }
+}

+ 2 - 2
lang/syn/src/codegen/program.rs

@@ -350,7 +350,7 @@ pub fn generate_non_inlined_handlers(program: &Program) -> proc_macro2::TokenStr
                     space as u64,
                     space as u64,
                     owner,
                     owner,
                 );
                 );
-                anchor_lang::solana_program::program::invoke_signed(
+                anchor_lang::cpi::invoke_signed(
                     &ix,
                     &ix,
                     &[
                     &[
                         accounts.from.clone(),
                         accounts.from.clone(),
@@ -1057,7 +1057,7 @@ fn generate_cpi(program: &Program) -> proc_macro2::TokenStream {
                         };
                         };
                         let mut acc_infos = ctx.accounts.to_account_infos();
                         let mut acc_infos = ctx.accounts.to_account_infos();
                         acc_infos.push(ctx.program.clone());
                         acc_infos.push(ctx.program.clone());
-                        anchor_lang::solana_program::program::invoke_signed(
+                        anchor_lang::cpi::invoke_signed(
                             &ix,
                             &ix,
                             &acc_infos,
                             &acc_infos,
                             ctx.signer_seeds,
                             ctx.signer_seeds,