mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
daemon/test: test mutual close with outstanding HTLCS.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5aed0e12f8
commit
97bc4ed0cb
3
Makefile
3
Makefile
@ -198,7 +198,8 @@ daemon-test-steal: daemon-test-dump-onchain
|
|||||||
daemon-test-dump-onchain: daemon-test-timeout-anchor
|
daemon-test-dump-onchain: daemon-test-timeout-anchor
|
||||||
daemon-test-timeout-anchor: daemon-test-normal
|
daemon-test-timeout-anchor: daemon-test-normal
|
||||||
daemon-test-normal: daemon-test-manual-commit
|
daemon-test-normal: daemon-test-manual-commit
|
||||||
daemon-test-manual-commit: daemon-all
|
daemon-test-manual-commit: daemon-test-mutual-close-with-htlcs
|
||||||
|
daemon-test-mutual-close-with-htlcs: daemon-all
|
||||||
|
|
||||||
daemon-tests: daemon-test-steal
|
daemon-tests: daemon-test-steal
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ while [ $# != 0 ]; do
|
|||||||
x"--manual-commit")
|
x"--manual-commit")
|
||||||
MANUALCOMMIT=1
|
MANUALCOMMIT=1
|
||||||
;;
|
;;
|
||||||
|
x"--mutual-close-with-htlcs")
|
||||||
|
CLOSE_WITH_HTLCS=1
|
||||||
|
;;
|
||||||
x"--normal")
|
x"--normal")
|
||||||
;;
|
;;
|
||||||
x"--verbose")
|
x"--verbose")
|
||||||
@ -544,6 +547,41 @@ lcli2 newhtlc $ID1 $HTLC_AMOUNT $EXPIRY $RHASH2
|
|||||||
|
|
||||||
check_status $(($A_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($A_FEE + $EXTRA_FEE)) '{ "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH'" } ' $(($B_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($B_FEE + $EXTRA_FEE)) '{ "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH2'" } '
|
check_status $(($A_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($A_FEE + $EXTRA_FEE)) '{ "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH'" } ' $(($B_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($B_FEE + $EXTRA_FEE)) '{ "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH2'" } '
|
||||||
|
|
||||||
|
if [ -n "$CLOSE_WITH_HTLCS" ]; then
|
||||||
|
# Now begin close
|
||||||
|
lcli1 close $ID2
|
||||||
|
|
||||||
|
# They should be waiting for it to clear up.
|
||||||
|
check_peerstate lcli1 STATE_CLEARING
|
||||||
|
check_peerstate lcli2 STATE_CLEARING
|
||||||
|
|
||||||
|
# Fail one, still waiting.
|
||||||
|
lcli2 failhtlc $ID1 $RHASH
|
||||||
|
check_peerstate lcli1 STATE_CLEARING
|
||||||
|
check_peerstate lcli2 STATE_CLEARING
|
||||||
|
|
||||||
|
# Fulfill the other causes them to actually complete the close.
|
||||||
|
lcli1 fulfillhtlc $ID2 $SECRET2
|
||||||
|
check_peerstate lcli1 STATE_MUTUAL_CLOSING
|
||||||
|
check_peerstate lcli2 STATE_MUTUAL_CLOSING
|
||||||
|
|
||||||
|
$CLI generate 1
|
||||||
|
|
||||||
|
check_peerstate lcli1 STATE_CLOSE_ONCHAIN_MUTUAL
|
||||||
|
check_peerstate lcli2 STATE_CLOSE_ONCHAIN_MUTUAL
|
||||||
|
|
||||||
|
# Give it 100 blocks.
|
||||||
|
$CLI generate 99
|
||||||
|
|
||||||
|
check_no_peers lcli1
|
||||||
|
check_no_peers lcli2
|
||||||
|
|
||||||
|
lcli1 stop
|
||||||
|
lcli2 stop
|
||||||
|
|
||||||
|
all_ok
|
||||||
|
fi
|
||||||
|
|
||||||
lcli2 failhtlc $ID1 $RHASH
|
lcli2 failhtlc $ID1 $RHASH
|
||||||
lcli1 fulfillhtlc $ID2 $SECRET2
|
lcli1 fulfillhtlc $ID2 $SECRET2
|
||||||
[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1
|
[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1
|
||||||
|
Loading…
Reference in New Issue
Block a user