Skip to content

Commit 61db0ce

Browse files
pcarranzavdwerner
authored andcommitted
chore: add local testing script
1 parent b757945 commit 61db0ce

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Arbitrum Sepolia testnet JSON-RPC provider URL for testing (e.g., Infura, Alchemy, etc.)
2+
INDEXER_TEST_JRPC_PROVIDER_URL=https://arbitrum-sepolia.infura.io/v3/your-project-id
3+
4+
# The Graph API key for querying subgraphs (from The Graph Studio)
5+
INDEXER_TEST_API_KEY=your-graph-api-key-here

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,41 @@ Creating a new release involves the following steps:
308308
yarn release <version>
309309
```
310310
311+
## Running tests locally
312+
313+
To run the tests locally, you'll need:
314+
1. Docker installed and running
315+
2. Node.js and Yarn
316+
3. An Arbitrum Sepolia testnet RPC provider (e.g., Infura, Alchemy)
317+
4. An API key from The Graph Studio for querying subgraphs
318+
319+
### Setup
320+
321+
1. Create a `.env` file in the root directory with your credentials. You can copy the example file as a template:
322+
```sh
323+
cp .env.example .env
324+
```
325+
326+
Then edit `.env` with your credentials:
327+
```plaintext
328+
# Your Arbitrum Sepolia testnet RPC endpoint
329+
INDEXER_TEST_JRPC_PROVIDER_URL=https://sepolia.infura.io/v3/your-project-id
330+
331+
# Your API key from The Graph Studio (https://thegraph.com/studio/)
332+
INDEXER_TEST_API_KEY=your-graph-api-key-here
333+
```
334+
335+
2. Run the tests:
336+
```sh
337+
bash scripts/run-tests.sh
338+
```
339+
340+
The script will:
341+
- Start a PostgreSQL container with the required test configuration
342+
- Load your credentials from the `.env` file
343+
- Run the test suite
344+
- Clean up the PostgreSQL container when done
345+
311346
# Copyright
312347

313348
Copyright &copy; 2020-2021 The Graph Foundation

scripts/run-tests.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Cleanup function to stop and remove the container
3+
cleanup() {
4+
echo "Cleaning up..."
5+
docker stop indexer-test-db >/dev/null 2>&1
6+
docker rm indexer-test-db >/dev/null 2>&1
7+
}
8+
9+
# Register the cleanup function to run on script exit
10+
trap cleanup EXIT
11+
12+
# Start PostgreSQL container with the same configuration as CI
13+
docker run -d \
14+
--name indexer-test-db \
15+
-e POSTGRES_DB=indexer_tests \
16+
-e POSTGRES_USER=testuser \
17+
-e POSTGRES_PASSWORD=testpass \
18+
-p 5432:5432 \
19+
postgres:13
20+
21+
# Wait for PostgreSQL to be ready
22+
echo "Waiting for PostgreSQL to be ready..."
23+
until docker exec indexer-test-db pg_isready > /dev/null 2>&1; do
24+
sleep 1
25+
done
26+
echo "PostgreSQL is ready!"
27+
28+
# Load environment variables from .env file
29+
if [ -f .env ]; then
30+
echo "Loading .env file..."
31+
source .env
32+
else
33+
echo "Warning: .env file not found"
34+
fi
35+
36+
# Run the tests
37+
echo "Running tests..."
38+
POSTGRES_TEST_HOST=localhost \
39+
POSTGRES_TEST_DATABASE=indexer_tests \
40+
POSTGRES_TEST_USERNAME=testuser \
41+
POSTGRES_TEST_PASSWORD=testpass \
42+
NODE_OPTIONS="--dns-result-order=ipv4first" \
43+
yarn test:ci

0 commit comments

Comments
 (0)