Browse Source

helpers.sh: make check_tx_spend able to check for a specific transaction.

It currently takes an unused "who to blame" argument, which doesn't
always make sense.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
fae7f68731
  1. 10
      daemon/test/scripts/helpers.sh
  2. 16
      daemon/test/test.sh

10
daemon/test/scripts/helpers.sh

@ -393,9 +393,15 @@ check_status()
check_tx_spend()
{
if check "$CLI getrawmempool | $FGREP '\"'"; then :;
local FAIL
FAIL=0
if [ $# = 1 ]; then
check "$CLI getrawmempool | $FGREP $1" || FAIL=1
else
echo "No tx in mempool:" >&2
check "$CLI getrawmempool | $FGREP '\"'" || FAIL=1
fi
if [ $FAIL = 1 ]; then
echo "No tx $1 in mempool:" >&2
$CLI getrawmempool >&2
exit 1
fi

16
daemon/test/test.sh

@ -74,7 +74,7 @@ check '[ `get_info_field "$LCLI2" blockheight` = $BLOCKHEIGHT ]'
if [ -n "$TIMEOUT_ANCHOR" ]; then
lcli1 dev-broadcast false
fi
lcli1 connect localhost $PORT2 $TX &
lcli1 connect localhost $PORT2 $FUND_INPUT_TX &
# Expect them to be waiting for anchor, and ack from other side.
check_peerstate lcli1 STATE_OPEN_WAIT_ANCHORDEPTH_AND_THEIRCOMPLETE
@ -130,7 +130,7 @@ if [ -n "$TIMEOUT_ANCHOR" ]; then
$CLI generate 6
# Now it should have spent the commit tx.
check_tx_spend lcli1
check_tx_spend
# 100 blocks pass
$CLI generate 100
@ -144,7 +144,7 @@ if [ -n "$TIMEOUT_ANCHOR" ]; then
fi
# Now make it pass anchor (should be in mempool: one block to bury it)
check_tx_spend lcli1
check_tx_spend
$CLI generate 1
check_peerstate lcli1 STATE_NORMAL
@ -289,7 +289,7 @@ if [ -n "$DUMP_ONCHAIN" ]; then
# lcli1 should have sent out commitment tx
check_peerstate lcli1 STATE_ERR_BREAKDOWN
check_tx_spend lcli1
check_tx_spend
# Mine it.
$CLI generate 1
@ -303,7 +303,7 @@ if [ -n "$DUMP_ONCHAIN" ]; then
$CLI generate 6
# Now, lcli1 should spend its own output.
check_tx_spend lcli1
check_tx_spend
check_peerstate lcli1 STATE_CLOSE_ONCHAIN_OUR_UNILATERAL
while [ $(blockheight) != $EXPIRY ]; do
@ -311,7 +311,7 @@ if [ -n "$DUMP_ONCHAIN" ]; then
done
# lcli1 should have gotten HTLC back.
check_tx_spend lcli1
check_tx_spend
# Now, after 10 blocks, should all be concluded.
$CLI generate 10
@ -413,7 +413,7 @@ if [ -n "$STEAL" ]; then
# Node1 should get really upset; node2 should steal the transaction.
check_peerstate lcli1 STATE_ERR_INFORMATION_LEAK
check_peerstate lcli2 STATE_CLOSE_ONCHAIN_CHEATED
check_tx_spend lcli2
check_tx_spend
# Give it "forever" blocks.
$CLI generate 10
@ -663,7 +663,7 @@ if [ ! -n "$MANUALCOMMIT" ]; then
$CLI generate 1
lcli2 connect localhost $PORT3 $TX2 &
check_tx_spend lcli2
check_tx_spend
$CLI generate 1
# Make sure it's STATE_NORMAL.

Loading…
Cancel
Save