mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
test: test commands during commit phase.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
4110376e87
commit
889db659c5
3 changed files with 84 additions and 3 deletions
|
@ -110,9 +110,8 @@ check()
|
||||||
# Try making time pass for the nodes (if on mocktime), then sleeping.
|
# Try making time pass for the nodes (if on mocktime), then sleeping.
|
||||||
if [ -n "$MOCKTIME" ]; then
|
if [ -n "$MOCKTIME" ]; then
|
||||||
MOCKTIME=$(($MOCKTIME + 1))
|
MOCKTIME=$(($MOCKTIME + 1))
|
||||||
# Some tests kill nodes, so ignore failure here.
|
lcli1 dev-mocktime $MOCKTIME
|
||||||
lcli1 dev-mocktime $MOCKTIME > /dev/null 2>&1 || true
|
lcli2 dev-mocktime $MOCKTIME
|
||||||
lcli2 dev-mocktime $MOCKTIME > /dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
i=$(($i + 1))
|
i=$(($i + 1))
|
||||||
|
@ -599,6 +598,38 @@ A_AMOUNT=$(($A_AMOUNT + $HTLC_AMOUNT))
|
||||||
B_AMOUNT=$(($B_AMOUNT - $HTLC_AMOUNT))
|
B_AMOUNT=$(($B_AMOUNT - $HTLC_AMOUNT))
|
||||||
check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE ""
|
check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE ""
|
||||||
|
|
||||||
|
# Now, test making more changes before receiving commit reply.
|
||||||
|
lcli2 dev-output $ID1 false
|
||||||
|
lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH
|
||||||
|
|
||||||
|
# Make sure node1 sends commit (in the background, since it will block!)
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 &
|
||||||
|
# node2 will consider this committed.
|
||||||
|
check_status_single lcli2 $(($B_AMOUNT - $EXTRA_FEE/2)) $(($B_FEE + $EXTRA_FEE/2)) "" $(($A_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE/2)) $(($A_FEE + $EXTRA_FEE/2)) '{ "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH'" } '
|
||||||
|
|
||||||
|
# Now send another offer, and enable node2 output.
|
||||||
|
lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH2
|
||||||
|
lcli2 dev-output $ID1 true
|
||||||
|
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1
|
||||||
|
|
||||||
|
# Both sides should be committed to htlcs
|
||||||
|
check_status $(($A_AMOUNT - $HTLC_AMOUNT*2 - $EXTRA_FEE)) $(($A_FEE + $EXTRA_FEE)) '{ "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH'" }, { "msatoshis" : '$HTLC_AMOUNT', "expiry" : { "second" : '$EXPIRY' }, "rhash" : "'$RHASH2'" } ' $(($B_AMOUNT - $EXTRA_FEE)) $(($B_FEE + $EXTRA_FEE)) ""
|
||||||
|
|
||||||
|
# Node2 collects the HTLCs.
|
||||||
|
lcli2 fulfillhtlc $ID1 $SECRET
|
||||||
|
lcli2 fulfillhtlc $ID1 $SECRET2
|
||||||
|
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1
|
||||||
|
[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2
|
||||||
|
|
||||||
|
# We transferred 2 * amount from A to B.
|
||||||
|
A_AMOUNT=$(($A_AMOUNT - $HTLC_AMOUNT * 2))
|
||||||
|
B_AMOUNT=$(($B_AMOUNT + $HTLC_AMOUNT * 2))
|
||||||
|
check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE ""
|
||||||
|
|
||||||
lcli1 close $ID2
|
lcli1 close $ID2
|
||||||
|
|
||||||
# They should be negotiating the close.
|
# They should be negotiating the close.
|
||||||
|
|
28
test/commits/06-change-while-commit-outstanding.script
Normal file
28
test/commits/06-change-while-commit-outstanding.script
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Test changes after committing but before receiving revocation.
|
||||||
|
A:offer 1
|
||||||
|
B:recvoffer
|
||||||
|
A:commit
|
||||||
|
A:offer 3
|
||||||
|
|
||||||
|
# Now B receives that commitment and counter-commits.
|
||||||
|
B:recvcommit
|
||||||
|
B:commit
|
||||||
|
|
||||||
|
A:recvrevoke
|
||||||
|
A:recvcommit
|
||||||
|
A:commit
|
||||||
|
|
||||||
|
B:recvoffer
|
||||||
|
B:recvrevoke
|
||||||
|
B:recvcommit
|
||||||
|
|
||||||
|
B:commit
|
||||||
|
A:recvrevoke
|
||||||
|
A:recvcommit
|
||||||
|
B:recvrevoke
|
||||||
|
|
||||||
|
checksync
|
||||||
|
echo ***A***
|
||||||
|
A:dump
|
||||||
|
echo ***B***
|
||||||
|
B:dump
|
|
@ -0,0 +1,22 @@
|
||||||
|
***A***
|
||||||
|
LOCAL COMMITS:
|
||||||
|
Commit 2:
|
||||||
|
Offered htlcs: 1 3
|
||||||
|
Received htlcs:
|
||||||
|
SIGNED
|
||||||
|
REMOTE COMMITS:
|
||||||
|
Commit 2:
|
||||||
|
Offered htlcs:
|
||||||
|
Received htlcs: 1 3
|
||||||
|
SIGNED
|
||||||
|
***B***
|
||||||
|
LOCAL COMMITS:
|
||||||
|
Commit 2:
|
||||||
|
Offered htlcs:
|
||||||
|
Received htlcs: 1 3
|
||||||
|
SIGNED
|
||||||
|
REMOTE COMMITS:
|
||||||
|
Commit 2:
|
||||||
|
Offered htlcs: 1 3
|
||||||
|
Received htlcs:
|
||||||
|
SIGNED
|
Loading…
Add table
Reference in a new issue