Skip to content

Commit f5538bd

Browse files
committed
daemon: test scripts.
We comment out the peer_create_close_tx() abort for now, so we can test. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 3c9fd4f commit f5538bd

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ $(HELPER_OBJS) $(BITCOIN_OBJS) $(TEST_CLI_PROGRAMS:=.o) $(TEST_PROGRAMS:=.o): $(
203203
$(TEST_CLI_PROGRAMS:=.o): $(TEST_CLI_HEADERS)
204204

205205
# These don't work in parallel, so we open-code them
206-
test-cli-tests: $(TEST_CLI_PROGRAMS)
206+
test-cli-tests: $(TEST_CLI_PROGRAMS) daemon-all
207207
cd test-cli; scripts/shutdown.sh 2>/dev/null || true
208+
set -e; for args in ""; do daemon/test/test.sh; done
208209
set -e; cd test-cli; for args in "" --steal --unilateral --htlc-onchain; do scripts/setup.sh && scripts/test.sh $$args && scripts/shutdown.sh; done
209210

210211
test-onion: test/test_onion test/onion_key

daemon/peer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void peer_watch_htlc_spend(struct peer *peer,
594594
const struct htlc *htlc,
595595
enum state_input done)
596596
{
597-
FIXME_STUB(peer);
597+
/* FIXME! */
598598
}
599599
void peer_unwatch_htlc_spend(struct peer *peer,
600600
const struct htlc *htlc,

daemon/test/test.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#! /bin/sh -e
2+
3+
# We steal the test-cli scripts.
4+
cd test-cli
5+
6+
. scripts/vars.sh
7+
8+
scripts/setup.sh
9+
10+
DIR1=/tmp/lightning.$$.1
11+
DIR2=/tmp/lightning.$$.2
12+
13+
LCLI1="../daemon/lightning-cli --lightning-dir=$DIR1"
14+
LCLI2="../daemon/lightning-cli --lightning-dir=$DIR2"
15+
16+
trap "echo Results in $DIR1 and $DIR2" EXIT
17+
mkdir $DIR1 $DIR2
18+
../daemon/lightningd --log-level=debug --lightning-dir=$DIR1 > $DIR1/output &
19+
../daemon/lightningd --log-level=debug --lightning-dir=$DIR2 > $DIR2/output &
20+
21+
i=0
22+
while ! $LCLI1 getlog | grep Hello; do
23+
sleep 1
24+
i=$(($i + 1))
25+
if [ $i -gt 10 ]; then
26+
echo Failed to start daemon 1 >&2
27+
exit 1
28+
fi
29+
done
30+
31+
while ! $LCLI2 getlog | grep 'listener on port'; do
32+
sleep 1
33+
i=$(($i + 1))
34+
if [ $i -gt 10 ]; then
35+
echo Failed to start daemon 2 >&2
36+
exit 1
37+
fi
38+
done
39+
40+
PORT2=`$LCLI2 getlog | sed -n 's/.*on port \([0-9]*\).*/\1/p'`
41+
42+
$LCLI1 connect localhost $PORT2 999999
43+
sleep 1
44+
45+
# Expect them to be waiting for anchor.
46+
$LCLI1 getpeers | grep STATE_OPEN_WAITING_OURANCHOR
47+
$LCLI2 getpeers | grep STATE_OPEN_WAITING_THEIRANCHOR
48+
49+
# Now make it pass anchor.
50+
$CLI generate 3
51+
52+
# FIXME: Speed this up!
53+
sleep 30
54+
55+
$LCLI1 getpeers | grep STATE_NORMAL_HIGHPRIO
56+
$LCLI2 getpeers | grep STATE_NORMAL_LOWPRIO
57+
58+
$LCLI1 stop
59+
$LCLI2 stop
60+
scripts/shutdown.sh
61+
62+
trap "rm -rf $DIR1 $DIR2" EXIT
63+

0 commit comments

Comments
 (0)