@@ -44,43 +44,37 @@ jobs:
4444 - name : Acquire test accounts
4545 id : accounts
4646 run : |
47- # Query daemon for accounts already in its wallet (pre-loaded by lightnet)
48- WALLETS_QUERY='{ ownedWallets { publicKey locked } }'
49- for i in $(seq 1 30); do
50- RESULT=$(curl -s http://127.0.0.1:8080/graphql \
51- -H "Content-Type: application/json" \
52- -d "{\"query\": \"$WALLETS_QUERY\"}")
53- echo "Wallet query attempt $i: $RESULT"
54- WALLET_COUNT=$(echo "$RESULT" | python3 -c "
55- import sys, json
56- d = json.load(sys.stdin)
57- wallets = d.get('data', {}).get('ownedWallets') or []
58- print(len(wallets))
59- " 2>/dev/null)
60- if [ "$WALLET_COUNT" -gt "1" ] 2>/dev/null; then
47+ # The faucet's unlockAccount=true imports and unlocks the key in the
48+ # daemon wallet. This can fail if the daemon's keystore isn't ready yet,
49+ # so retry with back-off.
50+ for i in $(seq 1 60); do
51+ SENDER=$(curl -sf "http://127.0.0.1:8181/acquire-account?unlockAccount=true" 2>/dev/null || true)
52+ if echo "$SENDER" | python3 -c "import sys,json; d=json.load(sys.stdin); assert 'pk' in d" 2>/dev/null; then
53+ echo "Sender acquired on attempt $i"
6154 break
6255 fi
56+ echo "Attempt $i/60 - waiting for account faucet... Response: $SENDER"
57+ # Release the failed account back if it was acquired but unlock failed
58+ if echo "$SENDER" | grep -q '"code":500' 2>/dev/null; then
59+ # The account wasn't returned since it errored, try fresh
60+ true
61+ fi
6362 sleep 10
6463 done
6564
66- # Pick sender (first wallet) and receiver (second wallet), unlock sender
67- read SENDER_PK RECEIVER_PK <<< $(echo "$RESULT" | python3 -c "
68- import sys, json
69- d = json.load(sys.stdin)
70- wallets = d['data']['ownedWallets']
71- print(wallets[0]['publicKey'], wallets[1]['publicKey'])
72- ")
65+ SENDER_PK=$(echo "$SENDER" | python3 -c "import sys,json; print(json.load(sys.stdin)['pk'])")
66+ if [ -z "$SENDER_PK" ]; then
67+ echo "::error::Failed to acquire sender account"
68+ exit 1
69+ fi
7370
74- # Unlock sender if locked
75- UNLOCK_QUERY='mutation(\$input: UnlockInput!) { unlockAccount(input: \$input) { publicKey } }'
76- curl -s http://127.0.0.1:8080/graphql \
77- -H "Content-Type: application/json" \
78- -d "{\"query\": \"$UNLOCK_QUERY\", \"variables\": {\"input\": {\"publicKey\": \"$SENDER_PK\", \"password\": \"\"}}}"
71+ RECEIVER=$(curl -s "http://127.0.0.1:8181/acquire-account")
72+ RECEIVER_PK=$(echo "$RECEIVER" | python3 -c "import sys,json; print(json.load(sys.stdin)['pk'])")
7973
8074 echo "sender_pk=$SENDER_PK" >> "$GITHUB_OUTPUT"
8175 echo "receiver_pk=$RECEIVER_PK" >> "$GITHUB_OUTPUT"
82- echo "Sender PK : $SENDER_PK"
83- echo "Receiver PK : $RECEIVER_PK"
76+ echo "Sender: $SENDER_PK"
77+ echo "Receiver: $RECEIVER_PK"
8478
8579 - name : Run integration tests
8680 env :
0 commit comments