File tree Expand file tree Collapse file tree 4 files changed +60
-25
lines changed
Expand file tree Collapse file tree 4 files changed +60
-25
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,16 @@ extend = "js-base"
2626dependencies = [" js-install" ]
2727args = [" lint" ]
2828
29+ [tasks .js-test ]
30+ script = [
31+ " ./scripts/start-test-validator.sh" ,
32+ " cd ${MANIFEST_DIR}" ,
33+ " pnpm install" ,
34+ " pnpm build" ,
35+ " pnpm test" ,
36+ " ./scripts/stop-test-validator.sh" ,
37+ ]
38+
2939
3040# Rust Tasks
3141
Original file line number Diff line number Diff line change @@ -9,33 +9,11 @@ import {
99} from './helpers/utils.mts' ;
1010
1111enum Command {
12- Test = 'test' ,
1312 Publish = 'publish' ,
1413}
1514
1615const { command, libraryPath, args } = parseCliArguments ( ) ;
1716
18- async function pnpm (
19- command : string ,
20- build = false ,
21- ) {
22- const [ pnpmArgs , commandArgs ] = partitionArguments ( args , '--' ) ;
23- cd ( libraryPath ) ;
24- await $ `pnpm install` ;
25- if ( build ) {
26- await $ `pnpm build` ;
27- }
28- await $ `pnpm ${ command } ${ pnpmArgs } -- ${ commandArgs } ` ;
29- }
30-
31- async function test ( ) {
32- // Start the local validator, or restart it if it is already running.
33- await $ `pnpm validator:restart` ;
34-
35- // Build the client and run the tests.
36- return pnpm ( 'test' , true ) ;
37- }
38-
3917async function publish ( ) {
4018 const [ level , tag = 'latest' ] = args ;
4119 if ( ! level ) {
@@ -72,9 +50,6 @@ async function publish() {
7250
7351
7452switch ( command ) {
75- case Command . Test :
76- await test ( ) ;
77- break ;
7853 case Command . Publish :
7954 await publish ( ) ;
8055 break ;
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+
4+ PORT=8899
5+ LOG_FILE=" ./test-ledger/validator.log"
6+
7+ PID=$( lsof -t -i:$PORT )
8+
9+ if [ -n " $PID " ]; then
10+ echo " Detected test validator running on PID $PID . Restarting..."
11+ kill " $PID "
12+ sleep 1
13+ fi
14+
15+ echo " Starting Solana test validator..."
16+ solana-test-validator > /dev/null 2>&1 &
17+ VALIDATOR_PID=$!
18+
19+ # Wait for test validator to move past slot 0.
20+ echo -n " Waiting for validator to stabilize"
21+ for i in {1..8}; do
22+ if ! kill -0 " $VALIDATOR_PID " 2> /dev/null; then
23+ echo -e " \nTest validator exited early."
24+ exit 1
25+ fi
26+
27+ SLOT=$( solana slot -ul 2> /dev/null)
28+ if [[ " $SLOT " =~ ^[0-9]+$ ]] && [ " $SLOT " -gt 0 ]; then
29+ echo -e " \nTest validator is ready. Slot: $SLOT "
30+ exit 0
31+ fi
32+
33+ echo -n " ."
34+ sleep 2
35+ done
36+
37+ echo -e " \nTimed out waiting for test validator to stabilize."
38+ exit 1
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ PORT=8899
4+
5+ if lsof -t -i:$PORT > /dev/null; then
6+ echo " Stopping test validator..."
7+ pkill -f solana-test-validator
8+ sleep 1
9+ echo " Test validator terminated."
10+ else
11+ echo " Test validator is not running."
12+ fi
You can’t perform that action at this time.
0 commit comments