mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 10:39:49 +01:00
ce96812ef0
This significantly reduces re-testing of the same paths, and simplifies the addition of new tests. make check -j12 times: Before: 9m24.973s After: 7m52.005s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
87 lines
2.9 KiB
Bash
Executable File
87 lines
2.9 KiB
Bash
Executable File
#! /bin/sh -e
|
|
|
|
# Wherever we are, we want to be in daemon/test dir.
|
|
cd `git rev-parse --show-toplevel`/daemon/test
|
|
|
|
. scripts/vars.sh
|
|
. scripts/helpers.sh
|
|
|
|
parse_cmdline 2 "$@"
|
|
setup_lightning 2
|
|
start_lightningd 2
|
|
|
|
lcli1 connect localhost $PORT2 $FUND_INPUT_TX &
|
|
|
|
# Now make it pass anchor (should be in mempool: one block to bury it)
|
|
check_tx_spend
|
|
$CLI generate 1
|
|
|
|
DO_RECONNECT=$RECONNECT
|
|
|
|
check_peerstate lcli1 STATE_NORMAL
|
|
check_peerstate lcli2 STATE_NORMAL
|
|
|
|
A_AMOUNT=$(($AMOUNT - $NO_HTLCS_FEE))
|
|
A_FEE=$NO_HTLCS_FEE
|
|
B_AMOUNT=0
|
|
B_FEE=0
|
|
check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE ""
|
|
|
|
# 100k satoshi should cover fees.
|
|
HTLC_AMOUNT=100000000
|
|
EXPIRY=$(( $(blockheight) + 10))
|
|
RHASH3=`lcli2 invoice $HTLC_AMOUNT RHASH3 | sed 's/.*"\([0-9a-f]*\)".*/\1/'`
|
|
|
|
lcli2 listinvoice
|
|
[ "`lcli2 listinvoice | tr -s '\012\011\" ' ' '`" = "[ { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : false } ] " ]
|
|
|
|
HTLCID3=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH3 | extract_id`
|
|
|
|
# We transferred amount from A to B, but fee now split evenly.
|
|
A_AMOUNT=$(($A_AMOUNT - $HTLC_AMOUNT + $NO_HTLCS_FEE / 2))
|
|
B_AMOUNT=$(($B_AMOUNT + $HTLC_AMOUNT - $NO_HTLCS_FEE / 2))
|
|
A_FEE=$(($NO_HTLCS_FEE / 2))
|
|
B_FEE=$(($NO_HTLCS_FEE / 2))
|
|
check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE ""
|
|
|
|
[ "`lcli2 listinvoice | tr -s '\012\011\" ' ' '`" = "[ { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : true } ] " ]
|
|
|
|
# Now, failed payment (didn't pay enough)
|
|
RHASH4=`lcli2 invoice $HTLC_AMOUNT RHASH4 | sed 's/.*"\([0-9a-f]*\)".*/\1/'`
|
|
|
|
# Shouldn't have this already.
|
|
if lcli2 getlog | $FGREP 'Short payment for'; then exit 1; fi
|
|
|
|
# Test listinvoice with both, or subset (either order possible!)
|
|
INVOICES=`lcli2 listinvoice | tr -s '\012\011\" ' ' '`
|
|
[ "$INVOICES" = "[ { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : true }, { label : RHASH4 , rhash : $RHASH4 , msatoshi : $HTLC_AMOUNT, complete : false } ] " ] || [ "$INVOICES" = "[ { label : RHASH4 , rhash : $RHASH4 , msatoshi : $HTLC_AMOUNT, complete : false }, { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : true } ] " ]
|
|
[ "`lcli2 listinvoice RHASH3 | tr -s '\012\011\" ' ' '`" = "[ { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : true } ] " ]
|
|
[ "`lcli2 listinvoice RHASH4 | tr -s '\012\011\" ' ' '`" = "[ { label : RHASH4 , rhash : $RHASH4 , msatoshi : $HTLC_AMOUNT, complete : false } ] " ]
|
|
|
|
HTLCID4=`lcli1 dev-newhtlc $ID2 $(($HTLC_AMOUNT - 1)) $EXPIRY $RHASH4 | extract_id`
|
|
|
|
check lcli2 "getlog | $FGREP 'Short payment for'"
|
|
check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE ""
|
|
|
|
lcli2 delinvoice RHASH4
|
|
if lcli2 delinvoice RHASH3 >/dev/null; then
|
|
echo "Should not be able to delete completed invoice!" >&2
|
|
exit 1
|
|
fi
|
|
|
|
lcli1 close $ID2
|
|
|
|
# They should be negotiate the close.
|
|
check_tx_spend
|
|
|
|
# Bury it in "forever" blocks.
|
|
$CLI generate 10
|
|
|
|
check_no_peers lcli1
|
|
check_no_peers lcli2
|
|
|
|
lcli1 stop
|
|
lcli2 stop
|
|
|
|
all_ok
|