1818 # vX_Y
1919 type : string
2020 secrets :
21- TEST_NODE_URL :
22- required : false
23- TEST_WS_JUNO :
21+ # Base domain of the Starknet Foundation nodes (bare host, no scheme or path).
22+ # Not needed when use-devnet is set.
23+ SNF_NODE_URL :
2424 required : false
2525 TEST_ACCOUNT_PRIVATE_KEY :
2626 required : false
@@ -40,11 +40,12 @@ jobs:
4040 - 5050:5050
4141
4242 env :
43- PROTOCOL : ${{ inputs.protocol == 'WS' && 'wss' || 'https' }}
43+ USE_DEVNET : ${{ inputs.use-devnet }}
44+ IS_WS : ${{ inputs.protocol == 'WS' }}
4445 NODE : ${{ inputs.node == 'Juno' && 'juno' || inputs.node == 'Pathfinder' && 'pathfinder' || '' }}
4546 VERSION : ${{ inputs.version }}
4647
47- NODE_URL : ${{ secrets.TEST_NODE_URL }}
48+ SNF_NODE_URL : ${{ secrets.SNF_NODE_URL }}
4849 TEST_ACCOUNT_PRIVATE_KEY : ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
4950 TEST_ACCOUNT_ADDRESS : ${{ secrets.TEST_ACCOUNT_ADDRESS }}
5051
@@ -57,21 +58,43 @@ jobs:
5758 - run : npm ci --ignore-scripts
5859 - run : npm run pretest && npm run posttest
5960 if : ${{ !inputs.ignore-scripts }}
60- - id : env-modification
61- name : env modification
61+ - id : node-url
62+ name : resolve node urls
63+ # Against the devnet service started above, the url is fixed. Otherwise the
64+ # urls are built from the Starknet Foundation base domain:
65+ # https://sepolia.<domain>/<node>/rpc/<version>
66+ # wss://sepolia.<domain>/<node>/ws/<version>
67+ # The WS suites also drive an account, so an rpc url is always needed.
6268 run : |
63- echo "::add-mask::$FORMATED_URL"
64- echo "NODE_URL=$FORMATED_URL" >> "$GITHUB_OUTPUT"
65- env :
66- FORMATED_URL : ${{ format(env.NODE_URL, env.PROTOCOL, env.NODE, env.VERSION) }}
69+ if [ "$USE_DEVNET" = 'true' ]; then
70+ rpc_url='http://127.0.0.1:5050/rpc'
71+ elif [ -n "$SNF_NODE_URL" ] && [ -n "$NODE" ] && [ -n "$VERSION" ]; then
72+ base="sepolia.$SNF_NODE_URL/$NODE"
73+ rpc_url="https://$base/rpc/$VERSION"
74+ echo "::add-mask::$rpc_url"
75+ if [ "$IS_WS" = 'true' ]; then
76+ ws_url="wss://$base/ws/$VERSION"
77+ echo "::add-mask::$ws_url"
78+ fi
79+ else
80+ echo "::error::No node url available: set use-devnet, or provide the node and version inputs together with the SNF_NODE_URL secret."
81+ exit 1
82+ fi
83+ echo "rpc-url=$rpc_url" >> "$GITHUB_OUTPUT"
84+ echo "ws-url=$ws_url" >> "$GITHUB_OUTPUT"
6785 - id : run-tests
6886 name : run tests
6987 run : |
7088 args=()
71- [[ "${{ inputs.protocol }}" == "WS" ]] && args+=( '__tests__/WebSocket' )
72- npm run test:coverage "${args[@]}"
89+ # --forceExit: the WebSocket suite exercises auto-reconnection against a
90+ # live gateway that (on Pathfinder) never completes the closing handshake
91+ # of a still-subscribed socket, leaving an open handle that would keep
92+ # Jest from exiting after the run completes. The `--` lets npm forward the
93+ # flag through to Jest.
94+ [[ "${{ inputs.protocol }}" == "WS" ]] && args+=( '--forceExit' '__tests__/WebSocket' )
95+ npm run test:coverage -- "${args[@]}"
7396 env :
74- TEST_RPC_URL : ${{ inputs.protocol != 'WS' && steps.env-modification .outputs.NODE_URL || null }}
75- TEST_WS_URL : ${{ inputs.protocol == 'WS' && (env.NODE == 'juno' && secrets.TEST_WS_JUNO || steps.env-modification .outputs.NODE_URL) || null }}
97+ TEST_RPC_URL : ${{ steps.node-url .outputs.rpc-url }}
98+ TEST_WS_URL : ${{ steps.node-url .outputs.ws-url }}
7699 TEST_ACCOUNT_PRIVATE_KEY : ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
77100 TEST_ACCOUNT_ADDRESS : ${{ secrets.TEST_ACCOUNT_ADDRESS }}
0 commit comments