Skip to content

Commit 9d983c0

Browse files
committed
initial version
1 parent 0a3b63f commit 9d983c0

File tree

3 files changed

+175
-74
lines changed

3 files changed

+175
-74
lines changed

.github/workflows/integration-test.yml

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -155,59 +155,62 @@ jobs:
155155
echo "${ZOMBIENET_BIN_DIR}" >> "$GITHUB_PATH"
156156
echo "ZOMBIENET_BINARY=zombienet-linux-x64" >> "$GITHUB_ENV"
157157
158-
# Westend parachain
159-
- name: Run authorize and store (PAPI, RPC node, Westend parachain)
158+
# Westend parachain tests
159+
- name: Start services (Westend parachain)
160160
working-directory: examples
161161
run: |
162162
export TEST_DIR="$(mktemp -d $GITHUB_WORKSPACE/bulletin-tests-run-XXXXX)/test"
163163
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
164164
mkdir -p "$TEST_DIR"
165-
just run-authorize-and-store "bulletin-westend-runtime" "ws"
166-
- name: Run authorize and store (PAPI, smoldot, Westend parachain)
165+
just start-services "bulletin-westend-runtime"
166+
- name: Test authorize and store (PAPI, RPC node, Westend parachain)
167167
working-directory: examples
168-
run: |
169-
export TEST_DIR="$(mktemp -d $GITHUB_WORKSPACE/bulletin-tests-run-XXXXX)/test"
170-
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
171-
mkdir -p "$TEST_DIR"
172-
just run-authorize-and-store "bulletin-westend-runtime" "smoldot"
173-
- name: Run store chunked data + DAG-PB (PJS-API, RPC node, Westend parachain)
168+
run: just test-authorize-and-store "bulletin-westend-runtime" "ws"
169+
- name: Test authorize and store (PAPI, smoldot, Westend parachain)
174170
working-directory: examples
175-
run: |
176-
export TEST_DIR="$(mktemp -d $GITHUB_WORKSPACE/bulletin-tests-run-XXXXX)/test"
177-
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
178-
mkdir -p "$TEST_DIR"
179-
just run-store-chunked-data "bulletin-westend-runtime"
171+
run: just test-authorize-and-store "bulletin-westend-runtime" "smoldot"
172+
- name: Test store chunked data + DAG-PB (PJS-API, RPC node, Westend parachain)
173+
working-directory: examples
174+
run: just test-store-chunked-data "bulletin-westend-runtime"
175+
- name: Stop services (Westend parachain)
176+
if: always()
177+
working-directory: examples
178+
run: just stop-services
179+
- name: Upload Westend logs (on failure)
180+
if: failure()
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: westend-failed-logs
184+
path: |
185+
${{ env.TEST_DIR }}/*.log
180186
181187
# TODO: Polkadot parachain
182188

183-
# Polkadot solochain
184-
- name: Run authorize and store (PAPI, RPC node, Polkadot solochain)
189+
# Polkadot solochain tests
190+
- name: Start services (Polkadot solochain)
185191
working-directory: examples
186192
run: |
187193
export TEST_DIR="$(mktemp -d $GITHUB_WORKSPACE/bulletin-tests-run-XXXXX)/test"
188194
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
189195
mkdir -p "$TEST_DIR"
190-
just run-authorize-and-store "bulletin-polkadot-runtime" "ws"
191-
- name: Run authorize and store (PAPI, smoldot, Polkadot solochain)
196+
just start-services "bulletin-polkadot-runtime"
197+
- name: Test authorize and store (PAPI, RPC node, Polkadot solochain)
192198
working-directory: examples
193-
run: |
194-
export TEST_DIR="$(mktemp -d $GITHUB_WORKSPACE/bulletin-tests-run-XXXXX)/test"
195-
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
196-
mkdir -p "$TEST_DIR"
197-
just run-authorize-and-store "bulletin-polkadot-runtime" "smoldot"
198-
- name: Run store chunked data + DAG-PB (PJS-API, RPC node, Polkadot solochain)
199+
run: just test-authorize-and-store "bulletin-polkadot-runtime" "ws"
200+
- name: Test authorize and store (PAPI, smoldot, Polkadot solochain)
199201
working-directory: examples
200-
run: |
201-
export TEST_DIR="$(mktemp -d $GITHUB_WORKSPACE/bulletin-tests-run-XXXXX)/test"
202-
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
203-
mkdir -p "$TEST_DIR"
204-
just run-store-chunked-data "bulletin-polkadot-runtime"
205-
206-
# Collects logs from the last failed zombienet run.
207-
- name: Upload Zombienet logs (on failure)
202+
run: just test-authorize-and-store "bulletin-polkadot-runtime" "smoldot"
203+
- name: Test store chunked data + DAG-PB (PJS-API, RPC node, Polkadot solochain)
204+
working-directory: examples
205+
run: just test-store-chunked-data "bulletin-polkadot-runtime"
206+
- name: Stop services (Polkadot solochain)
207+
if: always()
208+
working-directory: examples
209+
run: just stop-services
210+
- name: Upload Polkadot logs (on failure)
208211
if: failure()
209212
uses: actions/upload-artifact@v4
210213
with:
211-
name: failed-zombienet-logs
214+
name: polkadot-failed-logs
212215
path: |
213216
${{ env.TEST_DIR }}/*.log

examples/README.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,52 @@ Install just with:
99
- `brew install just`, if you're on Mac OS and have `brew` package manager installed,
1010
- `sudo apt install just`, if you're using a Linux distribution.
1111

12-
### Run prerequisites
13-
14-
It's only needed once after checkout or when dependencies change:
15-
- `just build`
16-
- `just npm-install`
17-
18-
### Run full workflow example
19-
- `just run-authorize-and-store papi` - for PAPI,
20-
- `just run-authorize-and-store pjs` - for PJS.
21-
22-
#### Run individual commands for manual testing
23-
- `just setup-services papi` - Setup all services (IPFS, zombienet, reconnect, PAPI descriptors),
24-
- `just ipfs-init` - Initialize IPFS (if needed),
25-
- `just ipfs-start` - Start IPFS daemon,
26-
- `just bulletin-solo-zombienet-start` - Start zombienet,
27-
- `just ipfs-connect` - Connect to IPFS nodes,
28-
- `just ipfs-reconnect-start` - Start IPFS reconnect script,
29-
- `just papi-generate` - Generate PAPI descriptors,
30-
- `just run-example papi` - Run example with PAPI or PJS,
31-
- `just teardown-services` - Stop all services
12+
### Quick Start - Run Tests
13+
14+
Start services once, run tests, then tear down:
15+
16+
```bash
17+
# 1. Start services for your runtime (only needed once)
18+
just start-services bulletin-westend-runtime
19+
# or
20+
just start-services bulletin-polkadot-runtime
21+
22+
# 2. Run tests (as many as you want)
23+
just test-authorize-and-store bulletin-westend-runtime ws
24+
just test-authorize-and-store bulletin-westend-runtime smoldot
25+
just test-store-chunked-data bulletin-westend-runtime
26+
27+
# 3. Stop services when done
28+
just stop-services
29+
```
30+
31+
**Performance:**
32+
- Environment startup: ~60-180 seconds (once)
33+
- Each test run: ~30-60 seconds
34+
- Total time for 3 tests: ~3-5 minutes (vs ~10-15 minutes if restarting environment each time)
35+
36+
### Available Runtimes
37+
38+
- `bulletin-westend-runtime` - Westend parachain configuration
39+
- `bulletin-polkadot-runtime` - Polkadot solochain configuration
40+
41+
### Available Test Commands
42+
43+
- `test-authorize-and-store <runtime> <mode>` - Test authorization and storage workflow
44+
- `mode` can be: `ws` (WebSocket RPC) or `smoldot` (light client)
45+
- `test-store-chunked-data <runtime>` - Test chunked data storage with DAG-PB
46+
47+
### Individual Service Commands (Advanced)
48+
49+
- `setup-parachain-prerequisites` - Install polkadot and polkadot-omni-node binaries
50+
- `bulletin-solo-zombienet-start <test_dir> <runtime>` - Start Polkadot solochain
51+
- `bulletin-westend-parachain-zombienet-start <test_dir> <runtime>` - Start Westend parachain
52+
- `ipfs-start <test_dir>` - Start IPFS Docker container
53+
- `ipfs-connect <runtime>` - Connect IPFS nodes
54+
- `ipfs-reconnect-start <test_dir> <runtime>` - Start IPFS reconnect script
55+
- `ipfs-shutdown <test_dir>` - Stop IPFS Docker container
56+
- `papi-generate` - Generate PAPI descriptors
57+
- `kill-pids <test_dir>` - Kill all background processes
3258

3359
## Manually
3460

examples/justfile

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,28 @@
22
#
33
# See README.md for usage instructions.
44

5-
# Default recipe - run the complete PAPI workflow test
6-
default: (run-authorize-and-store "bulletin-westend-runtime" "ws")
5+
# Default recipe - show available commands
6+
default:
7+
@echo "Polkadot Bulletin Chain - Just Commands"
8+
@echo ""
9+
@echo "Start environment and run tests:"
10+
@echo " just start-services <runtime> - Start services (westend/polkadot)"
11+
@echo " just test-authorize-and-store <runtime> <mode> - Run auth test (ws/smoldot)"
12+
@echo " just test-store-chunked-data <runtime> - Run chunked data test"
13+
@echo " just stop-services - Stop all services"
14+
@echo ""
15+
@echo "Available runtimes:"
16+
@echo " bulletin-westend-runtime - Westend parachain"
17+
@echo " bulletin-polkadot-runtime - Polkadot solochain"
18+
@echo ""
19+
@echo "Example workflow:"
20+
@echo " just start-services bulletin-westend-runtime"
21+
@echo " just test-authorize-and-store bulletin-westend-runtime ws"
22+
@echo " just test-store-chunked-data bulletin-westend-runtime"
23+
@echo " just stop-services"
24+
25+
# Test directory state file for persisting TEST_DIR between recipe calls
26+
TEST_DIR_FILE := justfile_directory() + "/.test-dir"
727

828
# Setup prerequisites for parachain runtime (polkadot and polkadot-omni-node binaries)
929
# This recipe clones polkadot-sdk, builds required binaries, and copies them to ~/local_bulletin_testing/bin
@@ -29,6 +49,22 @@ compute-test-dir:
2949
echo "$TEST_DIR";
3050
fi
3151

52+
# Save TEST_DIR to file for use across multiple recipe invocations
53+
save-test-dir test_dir:
54+
#!/usr/bin/env bash
55+
echo "{{ test_dir }}" > {{ TEST_DIR_FILE }}
56+
echo " Saved TEST_DIR to {{ TEST_DIR_FILE }}"
57+
58+
# Load TEST_DIR from file
59+
load-test-dir:
60+
#!/usr/bin/env bash
61+
if [ ! -f "{{ TEST_DIR_FILE }}" ]; then
62+
echo "❌ Error: No active test environment found"
63+
echo " Please run 'just start-services <runtime>' first"
64+
exit 1
65+
fi
66+
cat "{{ TEST_DIR_FILE }}"
67+
3268
# Install JavaScript dependencies
3369
npm-install:
3470
npm install
@@ -360,27 +396,65 @@ teardown-services test_dir:
360396
just ipfs-shutdown "{{ test_dir }}"
361397
echo "✅ Docker services stopped"
362398

363-
# Run authorize and store example with Docker IPFS
399+
# Start services and save TEST_DIR for subsequent test runs
400+
# Parameters:
401+
# runtime - Runtime name (e.g., "bulletin-polkadot-runtime", "bulletin-westend-runtime")
402+
start-services runtime: npm-install
403+
#!/usr/bin/env bash
404+
set -e
405+
406+
echo "🚀 Starting services for runtime: {{ runtime }}"
407+
408+
TEST_DIR="$(just compute-test-dir)"
409+
echo " Using TEST_DIR: $TEST_DIR"
410+
411+
just setup-services "$TEST_DIR" "{{ runtime }}"
412+
just save-test-dir "$TEST_DIR"
413+
414+
echo ""
415+
echo "✅ Services started successfully!"
416+
echo " TEST_DIR: $TEST_DIR"
417+
echo " You can now run tests with: just test-authorize-and-store {{ runtime }} <mode>"
418+
419+
# Stop services (uses saved TEST_DIR)
420+
stop-services:
421+
#!/usr/bin/env bash
422+
set -e
423+
424+
echo "🛑 Stopping services..."
425+
426+
TEST_DIR="$(just load-test-dir)"
427+
echo " Using TEST_DIR: $TEST_DIR"
428+
429+
just teardown-services "$TEST_DIR"
430+
431+
# Remove the saved TEST_DIR file
432+
rm -f "{{ TEST_DIR_FILE }}"
433+
echo " Removed {{ TEST_DIR_FILE }}"
434+
435+
echo "✅ Services stopped successfully!"
436+
437+
# Run authorize and store test (without setup/teardown, uses saved TEST_DIR)
364438
# Parameters:
439+
# runtime - Runtime name (e.g., "bulletin-polkadot-runtime", "bulletin-westend-runtime")
365440
# mode - Connection mode: "ws" (WebSocket RPC node) or "smoldot" (light client)
366-
# runtime - Runtime name (e.g., "bulletin-polkadot-runtime", "bulletin-westend-runtime", "polkadot-bulletin-chain-runtime")
367-
run-authorize-and-store runtime mode="ws": npm-install
441+
test-authorize-and-store runtime mode="ws":
368442
#!/usr/bin/env bash
369443
set -e
370444

371445
if [ "{{ mode }}" = "smoldot" ]; then
372-
echo "🚀 Starting authorize and store workflow test (mode: smoldot, runtime: {{ runtime }})..."
446+
echo "🧪 Running authorize and store test (mode: smoldot, runtime: {{ runtime }})..."
373447
SCRIPT_NAME="authorize_and_store_papi_smoldot.js"
374448
elif [ "{{ mode }}" = "ws" ]; then
375-
echo "🚀 Starting authorize and store workflow test (mode: ws, runtime: {{ runtime }})..."
449+
echo "🧪 Running authorize and store test (mode: ws, runtime: {{ runtime }})..."
376450
SCRIPT_NAME="authorize_and_store_papi.js"
377451
else
378452
echo "❌ Error: Invalid mode '{{ mode }}'. Must be 'ws' or 'smoldot'"
379453
exit 1
380454
fi
381455

382-
TEST_DIR="$(just compute-test-dir)"
383-
just setup-services "$TEST_DIR" "{{ runtime }}"
456+
TEST_DIR="$(just load-test-dir)"
457+
echo " Using TEST_DIR: $TEST_DIR"
384458

385459
set +e
386460
# Run the script with chainspec_path parameter only for smoldot mode
@@ -403,25 +477,24 @@ run-authorize-and-store runtime mode="ws": npm-install
403477
echo ""
404478
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
405479
if [ $EXAMPLE_EXIT -eq 0 ]; then
406-
echo "Example completed successfully!"
480+
echo "Test completed successfully!"
407481
else
408-
echo "Example failed with exit code $EXAMPLE_EXIT"
482+
echo "Test failed with exit code $EXAMPLE_EXIT"
409483
fi
410484

411-
just teardown-services "$TEST_DIR"
412485
exit $EXAMPLE_EXIT
413486

414-
# Run store chunked data example with Docker IPFS
487+
# Run store chunked data test (without setup/teardown, uses saved TEST_DIR)
415488
# Parameters:
416489
# runtime - Runtime name (e.g., "bulletin-polkadot-runtime", "bulletin-westend-runtime")
417-
run-store-chunked-data runtime: npm-install
490+
test-store-chunked-data runtime:
418491
#!/usr/bin/env bash
419492
set -e
420493

421-
echo "🚀 Starting store chunked data + DAG-PB workflow test (runtime: {{ runtime }})..."
494+
echo "🧪 Running store chunked data + DAG-PB test (runtime: {{ runtime }})..."
422495

423-
TEST_DIR="$(just compute-test-dir)"
424-
just setup-services "$TEST_DIR" "{{ runtime }}"
496+
TEST_DIR="$(just load-test-dir)"
497+
echo " Using TEST_DIR: $TEST_DIR"
425498

426499
set +e
427500
node store_chunked_data.js
@@ -430,10 +503,9 @@ run-store-chunked-data runtime: npm-install
430503
echo ""
431504
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
432505
if [ $EXAMPLE_EXIT -eq 0 ]; then
433-
echo "Example completed successfully!"
506+
echo "Test completed successfully!"
434507
else
435-
echo "Example failed with exit code $EXAMPLE_EXIT"
508+
echo "Test failed with exit code $EXAMPLE_EXIT"
436509
fi
437510

438-
just teardown-services "$TEST_DIR"
439511
exit $EXAMPLE_EXIT

0 commit comments

Comments
 (0)