Browse Source

Merge pull request #9 from dadepo/improvements-to-checking-accounts

Improvements to checking accounts
Joe Caulfield 2 years ago
parent
commit
6c5df49f41
2 changed files with 16 additions and 2 deletions
  1. 13 0
      basics/checking-accounts/README.md
  2. 3 2
      basics/checking-accounts/native/tests/test.ts

+ 13 - 0
basics/checking-accounts/README.md

@@ -0,0 +1,13 @@
+# Checking Accounts
+
+Solana Programs should perform checks on instructions to ensure security and that required invariants
+are not being violated.
+
+These checks vary and depend on the exact task of the Solana Program.
+
+In this example we see some of the common checks a Solana Program can perform:
+
+- checking the program ID from the instruction is the program ID of your program
+- checking that the order and number of accounts are correct
+- checking the initialization state of an account
+- etc.

+ 3 - 2
basics/checking-accounts/native/tests/test.ts

@@ -20,9 +20,10 @@ describe("Checking accounts", async () => {
 
     const connection = new Connection(`http://localhost:8899`, 'confirmed');
     const payer = createKeypairFromFile(require('os').homedir() + '/.config/solana/id.json');
-    
+    const program = createKeypairFromFile('./program/target/so/program-keypair.json');
+
     const PROGRAM_ID: PublicKey = new PublicKey(
-        ""
+        program.publicKey
     );
 
     // We'll create this ahead of time.