@@ -308,6 +308,49 @@ if [[ $1 == "swapserver_refund" ]]; then
308308fi
309309
310310
311+ if [[ $1 == " swapserver_server_skip_onchain_funding" ]]; then
312+ # Alice starts reverse-swap with Bob.
313+ # Alice sends hold-HTLCs via LN. Bob does NOT fund locking script onchain.
314+ # After a while, Alice requests Bob to force-close chan, and Bob does.
315+ # Alice will broadcast HTLC-timeout tx to reclaim the swap amount from Bob's commitment tx.
316+ $bob setconfig test_swapserver_skip_onchain_funding true
317+ wait_for_balance alice 1
318+ echo " alice opens channel"
319+ bob_node=$( $bob nodeid)
320+ channel=$( $alice open_channel $bob_node 0.15 --password=' ' )
321+ chan_funding_txid=$( echo " $channel " | cut -d " :" -f 1)
322+ chan_funding_outidx=$( echo " $channel " | cut -d " :" -f 2)
323+ new_blocks 3
324+ wait_until_channel_open alice
325+ echo " alice initiates swap"
326+ dryrun=$( $alice reverse_swap 0.02 dryrun)
327+ onchain_amount=$( echo $dryrun | jq -r " .onchain_amount" )
328+ # Alice starts a reverse-swap, but will time out waiting for Bob's swap-funding-tx to appear in mempool.
329+ $alice setconfig timeout 10
330+ set +e
331+ swap=$( $alice reverse_swap 0.02 $onchain_amount )
332+ set -e
333+ $alice unsetconfig timeout
334+ # After a while, Alice gets impatient and gets Bob to close the channel.
335+ new_blocks 20
336+ $alice request_force_close $channel
337+ wait_until_spent $chan_funding_txid $chan_funding_outidx
338+ new_blocks 1
339+ wait_until_channel_closed alice
340+ ctx_id=$( $alice list_channels | jq -r " .[0].closing_txid" )
341+ # need more blocks to reach CLTV of HTLC-output in ctx
342+ new_blocks 130
343+ if [ $TEST_ANCHOR_CHANNELS = True ] ; then
344+ htlc_output_index=3 # FIXME index depends on Alice not using MPP
345+ else
346+ htlc_output_index=1
347+ fi
348+ wait_until_spent $ctx_id $htlc_output_index
349+ new_blocks 1
350+ wait_for_balance alice 0.997
351+ fi
352+
353+
311354if [[ $1 == " extract_preimage" ]]; then
312355 # Alice sends htlc1 to Bob. Bob sends htlc2 to Alice.
313356 # Neither one of them settles, they hold the htlcs, and Bob force-closes.
0 commit comments