Skip to content

Commit

Permalink
improve(arlocal): avoid second process (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-a-morris authored Feb 20, 2024
1 parent 131e83e commit ecc1645
Show file tree
Hide file tree
Showing 4 changed files with 1,982 additions and 68 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
with:
node-version: 18
- run: yarn install
- name: Run local arweave node
run: yarn test:run:arweave &
- run: yarn test
env:
NODE_URL_1: ${{ secrets.NODE_URL_1 }}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@types/lodash.get": "^4.4.7",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"arlocal": "^1.1.65",
"chai": "^4.3.8",
"chai-exclude": "^2.1.0",
"dotenv": "^16.0.0",
Expand Down
9 changes: 9 additions & 0 deletions test/arweaveClient.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ArLocal from "arlocal";
import Arweave from "arweave";
import { JWKInterface } from "arweave/node/lib/wallet";
import axios from "axios";
Expand All @@ -20,11 +21,15 @@ const LOCAL_ARWEAVE_URL = `${LOCAL_ARWEAVE_NODE.protocol}://${LOCAL_ARWEAVE_NODE
const mineBlock = () => axios.get(`${LOCAL_ARWEAVE_URL}/mine`);

describe("ArweaveClient", () => {
const arLocal = new ArLocal(LOCAL_ARWEAVE_NODE.port, true);

let jwk: JWKInterface;
let client: ArweaveClient;
// Before running any of the tests, we need to fund the address with some AR
// so that we can post to our testnet node
before(async () => {
// Start the local arweave node
await arLocal.start();
// Generate a new JWK for our tests
jwk = await Arweave.init({}).wallets.generate();
// Resolve the address of the JWK
Expand Down Expand Up @@ -197,4 +202,8 @@ describe("ArweaveClient", () => {
);
await assertPromiseError(client.set({ test: "value" }), "You don't have enough tokens");
});

after(async () => {
await arLocal.stop();
});
});
Loading

0 comments on commit ecc1645

Please sign in to comment.