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
3369npm-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