Browse Source

test_forwarding: do not set HOME

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 6 years ago
parent
commit
d5006e83e7
  1. 58
      electrum/tests/test_forwarding/test_forwarding.sh

58
electrum/tests/test_forwarding/test_forwarding.sh

@ -1,41 +1,41 @@
#!/usr/bin/env bash
# alice -> bob -> carol # alice -> bob -> carol
ELECTRUM=./run_electrum ELECTRUM=./run_electrum
HOME=/tmp
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
echo "syntax: init|open|status|pay|close" echo "syntax: init|open|status|pay|close"
exit exit
fi fi
if [[ $1 == "init" ]]; then if [[ $1 == "init" ]]; then
rm -rf $HOME/alice/ $HOME/bob/ $HOME/carol/ rm -rf /tmp/alice/ /tmp/bob/ /tmp/carol/
$ELECTRUM create --regtest -D $HOME/alice/ $ELECTRUM create --regtest -D /tmp/alice/
$ELECTRUM create --regtest -D $HOME/bob/ $ELECTRUM create --regtest -D /tmp/bob/
$ELECTRUM create --regtest -D $HOME/carol/ $ELECTRUM create --regtest -D /tmp/carol/
$ELECTRUM setconfig --regtest -D $HOME/bob/ lightning_listen localhost:9735 $ELECTRUM setconfig --regtest -D /tmp/bob/ lightning_listen localhost:9735
bitcoin-cli -regtest sendtoaddress `$ELECTRUM getunusedaddress --regtest -D $HOME/alice/` 1 bitcoin-cli -regtest sendtoaddress `$ELECTRUM getunusedaddress --regtest -D /tmp/alice/` 1
bitcoin-cli -regtest sendtoaddress `$ELECTRUM getunusedaddress --regtest -D $HOME/bob/` 1 bitcoin-cli -regtest sendtoaddress `$ELECTRUM getunusedaddress --regtest -D /tmp/bob/` 1
bitcoin-cli -regtest sendtoaddress `$ELECTRUM getunusedaddress --regtest -D $HOME/carol/` 1 bitcoin-cli -regtest sendtoaddress `$ELECTRUM getunusedaddress --regtest -D /tmp/carol/` 1
bitcoin-cli -regtest generate 1 > /dev/null bitcoin-cli -regtest generate 1 > /dev/null
exit exit
fi fi
# start daemons. Bob is started first because he is listening # start daemons. Bob is started first because he is listening
$ELECTRUM daemon --regtest -D $HOME/bob/ -s 127.0.0.1:51001:t start $ELECTRUM daemon --regtest -D /tmp/bob/ -s 127.0.0.1:51001:t start
$ELECTRUM daemon --regtest -D $HOME/bob/ load_wallet $ELECTRUM daemon --regtest -D /tmp/bob/ load_wallet
$ELECTRUM daemon --regtest -D $HOME/alice/ -s 127.0.0.1:51001:t start $ELECTRUM daemon --regtest -D /tmp/alice/ -s 127.0.0.1:51001:t start
$ELECTRUM daemon --regtest -D $HOME/alice/ load_wallet $ELECTRUM daemon --regtest -D /tmp/alice/ load_wallet
$ELECTRUM daemon --regtest -D $HOME/carol/ -s 127.0.0.1:51001:t start $ELECTRUM daemon --regtest -D /tmp/carol/ -s 127.0.0.1:51001:t start
$ELECTRUM daemon --regtest -D $HOME/carol/ load_wallet $ELECTRUM daemon --regtest -D /tmp/carol/ load_wallet
if [[ $1 == "open" ]]; then if [[ $1 == "open" ]]; then
bob_node=$($ELECTRUM --regtest -D $HOME/bob/ nodeid) bob_node=$($ELECTRUM --regtest -D /tmp/bob/ nodeid)
channel_id1=$($ELECTRUM --regtest -D $HOME/alice/ open_channel $bob_node 0.001 --channel_push 0.001) channel_id1=$($ELECTRUM --regtest -D /tmp/alice/ open_channel $bob_node 0.001 --channel_push 0.001)
echo "Channel ID" $channel_id1 echo "Channel ID" $channel_id1
channel_id2=$($ELECTRUM --regtest -D $HOME/carol/ open_channel $bob_node 0.001 --channel_push 0.001) channel_id2=$($ELECTRUM --regtest -D /tmp/carol/ open_channel $bob_node 0.001 --channel_push 0.001)
echo "Channel ID" $channel_id2 echo "Channel ID" $channel_id2
echo "mining 3 blocks" echo "mining 3 blocks"
bitcoin-cli -regtest generate 3 bitcoin-cli -regtest generate 3
@ -43,29 +43,29 @@ fi
if [[ $1 == "status" ]]; then if [[ $1 == "status" ]]; then
sleep 3 sleep 3
$ELECTRUM --regtest -D $HOME/bob list_channels $ELECTRUM --regtest -D /tmp/bob list_channels
fi fi
if [[ $1 == "pay" ]]; then if [[ $1 == "pay" ]]; then
sleep 3 sleep 3
request=$($ELECTRUM --regtest -D $HOME/carol/ addinvoice 0.0001 "blah") request=$($ELECTRUM --regtest -D /tmp/carol/ addinvoice 0.0001 "blah")
echo $request echo $request
$ELECTRUM --regtest -D $HOME/alice/ lnpay $request $ELECTRUM --regtest -D /tmp/alice/ lnpay $request
# sleep before stopping nodes # sleep before stopping nodes
sleep 3 sleep 3
fi fi
if [[ $1 == "close" ]]; then if [[ $1 == "close" ]]; then
chan1=$($ELECTRUM --regtest -D $HOME/alice/ list_channels | jq -r ".[0].channel_point") chan1=$($ELECTRUM --regtest -D /tmp/alice/ list_channels | jq -r ".[0].channel_point")
chan2=$($ELECTRUM --regtest -D $HOME/carol/ list_channels | jq -r ".[0].channel_point") chan2=$($ELECTRUM --regtest -D /tmp/carol/ list_channels | jq -r ".[0].channel_point")
echo "Channel ID" $chan1 echo "Channel ID" $chan1
echo "Channel ID" $chan2 echo "Channel ID" $chan2
$ELECTRUM --regtest -D $HOME/alice/ close_channel $chan1 $ELECTRUM --regtest -D /tmp/alice/ close_channel $chan1
$ELECTRUM --regtest -D $HOME/carol/ close_channel $chan2 $ELECTRUM --regtest -D /tmp/carol/ close_channel $chan2
echo "mining 1 block" echo "mining 1 block"
bitcoin-cli -regtest generate 1 bitcoin-cli -regtest generate 1
fi fi
$ELECTRUM daemon --regtest -D $HOME/alice/ -s 127.0.0.1:51001:t stop $ELECTRUM daemon --regtest -D /tmp/alice/ -s 127.0.0.1:51001:t stop
$ELECTRUM daemon --regtest -D $HOME/bob/ -s 127.0.0.1:51001:t stop $ELECTRUM daemon --regtest -D /tmp/bob/ -s 127.0.0.1:51001:t stop
$ELECTRUM daemon --regtest -D $HOME/carol/ -s 127.0.0.1:51001:t stop $ELECTRUM daemon --regtest -D /tmp/carol/ -s 127.0.0.1:51001:t stop

Loading…
Cancel
Save