Bläddra i källkod

Fix JS client tests

Loris Leiva 1 år sedan
förälder
incheckning
97f9682c4c

+ 0 - 0
template/base/_gitignore → template/base/.gitignore


+ 1 - 1
template/clients/js/clients/js/test/increment.test.ts → template/clients/js/clients/js/test/increment.test.ts.njk

@@ -80,7 +80,7 @@ test('it cannot increment a counter that does not exist', async (t) => {
   );
   t.regex(
     error.data.logs.join('\n'),
-    /Account "counter" \[.+\] expected program owner \[MyProgram1111111111111111111111111111111111\], got \[11111111111111111111111111111111\]/
+    /Account "counter" \[.+\] expected program owner \[{{ programAddress }}\], got \[11111111111111111111111111111111\]/
   );
 });
 

+ 1 - 1
template/clients/js/scripts/client/test-js.mjs

@@ -3,7 +3,7 @@ import "zx/globals";
 import { workingDirectory } from "../utils.mjs";
 
 // Start the local validator if it's not already running.
-await $`pnpm validator`;
+await $`pnpm validator --force`;
 
 // Build the client and run the tests.
 cd(path.join(workingDirectory, "clients", "js"));

+ 1 - 1
template/clients/rust/scripts/client/test-rust.mjs

@@ -3,7 +3,7 @@ import "zx/globals";
 import { workingDirectory } from "../utils.mjs";
 
 // Start the local validator if it's not already running.
-await $`pnpm validator`;
+await $`pnpm validator --force`;
 
 // Run the tests.
 cd(path.join(workingDirectory, "clients", "rust"));

+ 0 - 184
template/programs/counter-shank/program/idl.json

@@ -1,184 +0,0 @@
-{
-  "version": "0.1.0",
-  "name": "acme_counter",
-  "instructions": [
-    {
-      "name": "Create",
-      "accounts": [
-        {
-          "name": "counter",
-          "isMut": true,
-          "isSigner": false,
-          "docs": [
-            "The program derived address of the counter account to create (seeds: ['counter', authority])"
-          ]
-        },
-        {
-          "name": "authority",
-          "isMut": false,
-          "isSigner": true,
-          "docs": [
-            "The authority of the counter"
-          ]
-        },
-        {
-          "name": "payer",
-          "isMut": true,
-          "isSigner": true,
-          "docs": [
-            "The account paying for the storage fees"
-          ]
-        },
-        {
-          "name": "systemProgram",
-          "isMut": false,
-          "isSigner": false,
-          "docs": [
-            "The system program"
-          ]
-        }
-      ],
-      "args": [],
-      "discriminant": {
-        "type": "u8",
-        "value": 0
-      }
-    },
-    {
-      "name": "Increment",
-      "accounts": [
-        {
-          "name": "counter",
-          "isMut": true,
-          "isSigner": false,
-          "docs": [
-            "The program derived address of the counter account to increment (seeds: ['counter', authority])"
-          ]
-        },
-        {
-          "name": "authority",
-          "isMut": false,
-          "isSigner": true,
-          "docs": [
-            "The authority of the counter"
-          ]
-        }
-      ],
-      "args": [
-        {
-          "name": "amount",
-          "type": {
-            "option": "u32"
-          }
-        }
-      ],
-      "discriminant": {
-        "type": "u8",
-        "value": 1
-      }
-    }
-  ],
-  "accounts": [
-    {
-      "name": "Counter",
-      "type": {
-        "kind": "struct",
-        "fields": [
-          {
-            "name": "key",
-            "type": {
-              "defined": "Key"
-            }
-          },
-          {
-            "name": "authority",
-            "type": "publicKey"
-          },
-          {
-            "name": "value",
-            "type": "u32"
-          }
-        ]
-      }
-    }
-  ],
-  "types": [
-    {
-      "name": "Key",
-      "type": {
-        "kind": "enum",
-        "variants": [
-          {
-            "name": "Uninitialized"
-          },
-          {
-            "name": "Counter"
-          }
-        ]
-      }
-    }
-  ],
-  "errors": [
-    {
-      "code": 0,
-      "name": "DeserializationError",
-      "msg": "Error deserializing an account"
-    },
-    {
-      "code": 1,
-      "name": "SerializationError",
-      "msg": "Error serializing an account"
-    },
-    {
-      "code": 2,
-      "name": "InvalidProgramOwner",
-      "msg": "Invalid program owner. This likely mean the provided account does not exist"
-    },
-    {
-      "code": 3,
-      "name": "InvalidPda",
-      "msg": "Invalid PDA derivation"
-    },
-    {
-      "code": 4,
-      "name": "ExpectedEmptyAccount",
-      "msg": "Expected empty account"
-    },
-    {
-      "code": 5,
-      "name": "ExpectedNonEmptyAccount",
-      "msg": "Expected non empty account"
-    },
-    {
-      "code": 6,
-      "name": "ExpectedSignerAccount",
-      "msg": "Expected signer account"
-    },
-    {
-      "code": 7,
-      "name": "ExpectedWritableAccount",
-      "msg": "Expected writable account"
-    },
-    {
-      "code": 8,
-      "name": "AccountMismatch",
-      "msg": "Account mismatch"
-    },
-    {
-      "code": 9,
-      "name": "InvalidAccountKey",
-      "msg": "Invalid account key"
-    },
-    {
-      "code": 10,
-      "name": "NumericalOverflow",
-      "msg": "Numerical overflow"
-    }
-  ],
-  "metadata": {
-    "origin": "shank",
-    "address": "MyProgram1111111111111111111111111111111111",
-    "binaryVersion": "0.4.2",
-    "libVersion": "^0.4.2"
-  }
-}

+ 1 - 6
utils/renderTemplates.ts

@@ -49,13 +49,8 @@ export function renderTemplate(ctx: RenderContext, src: string, dest: string) {
     return;
   }
 
-  // Rename `_file` to `.file`.
-  if (filename.startsWith("_")) {
-    dest = path.resolve(path.dirname(dest), filename.replace(/^_/, "."));
-  }
-
   // Append to existing .gitignore.
-  if (filename === "_gitignore" && fs.existsSync(dest)) {
+  if (filename === ".gitignore" && fs.existsSync(dest)) {
     const existing = fs.readFileSync(dest, "utf8");
     const newGitignore = fs.readFileSync(src, "utf8");
     fs.writeFileSync(dest, existing + "\n" + newGitignore);