From 2a1be06f287a4659449fd469d0e78ab0cc311455 Mon Sep 17 00:00:00 2001 From: dni Date: Fri, 12 Aug 2022 09:52:52 +0200 Subject: [PATCH] readd lnbits on lnd-3 fundingsource --- docker-compose.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ docker-scripts.sh | 27 +++++++++++++++++++++++++-- tests | 19 +++++++++++++------ 3 files changed, 80 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3bf527b..1cf62ce 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,30 @@ version: "3.7" services: + + lnbits: + hostname: lnbits + depends_on: + - boltz + - mempool-api + - lnd-3 + image: lnbitsdocker/lnbits-legend + restart: on-failure + user: "0:0" + entrypoint: "sh -c 'sleep 30; poetry run uvicorn lnbits.__main__:app --port 5001 --host lnbits'" + environment: + HOST: lnbits + DEBUG: true + LNBITS_BACKEND_WALLET_CLASS: "LndRestWallet" + LNBITS_DATA_FOLDER: "./data" + LND_REST_ENDPOINT: "https://lnd-3:8081/" + LND_REST_CERT: "./lnd/tls.cert" + LND_REST_MACAROON: "./lnd/data/chain/bitcoin/regtest/admin.macaroon" + ports: + - 5001:5001 + volumes: + - lnbits-data:/app/data + - ./data/lnd-3:/app/lnd:uid=1000,gid=1000 + boltz: hostname: boltz depends_on: @@ -76,6 +101,20 @@ services: volumes: - ./data/lnd-2:/root/.lnd/ + lnd-3: + hostname: lnd-3 + depends_on: + - bitcoind + image: boltz/lnd:0.14.2-beta + restart: on-failure + entrypoint: "sh -c 'sleep 20; lnd --listen=lnd-3:9735 --rpclisten=lnd-3:10009 --restlisten=lnd-3:8081 --bitcoin.active --bitcoin.regtest --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind --bitcoind.zmqpubrawtx=bitcoind:29000 --bitcoind.zmqpubrawblock=bitcoind:29001 --bitcoind.rpcuser=lnbits --bitcoind.rpcpass=lnbits --noseedbackup --protocol.wumbo-channels'" + expose: + - 8081 + - 9735 + - 10009 + volumes: + - ./data/lnd-3:/root/.lnd/ + electrs: depends_on: - bitcoind @@ -131,3 +170,6 @@ services: MYSQL_PASSWORD: "mempool" MYSQL_ROOT_PASSWORD: "admin" image: mariadb:10.5.8 + +volumes: + lnbits-data: diff --git a/docker-scripts.sh b/docker-scripts.sh index fe190a6..745bf5a 100644 --- a/docker-scripts.sh +++ b/docker-scripts.sh @@ -54,9 +54,9 @@ lnbits-regtest-start-log(){ lnbits-regtest-stop(){ docker compose down --volumes # clean up lightning node data - sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 ./data/boltz/boltz.db + sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/boltz/boltz.db # recreate lightning node data folders preventing permission errors - mkdir ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 + mkdir ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 } lnbits-regtest-restart(){ @@ -92,6 +92,7 @@ lnbits-lightning-init(){ fund_clightning_node 2 fund_lnd_node 1 fund_lnd_node 2 + fund_lnd_node 3 done echo "mining 10 blocks..." @@ -114,6 +115,13 @@ lnbits-lightning-init(){ bitcoin-cli-sim -generate 10 > /dev/null wait-for-lnd-channel 1 + # lnd-1 -> lnd-3 + lncli-sim 1 connect $(lncli-sim 3 getinfo | jq -r '.identity_pubkey')@lnbits-legend-lnd-3-1 > /dev/null + echo "open channel from lnd-1 to lnd-3" + lncli-sim 1 openchannel $(lncli-sim 3 getinfo | jq -r '.identity_pubkey') $channel_size $balance_size > /dev/null + bitcoin-cli-sim -generate 10 > /dev/null + wait-for-lnd-channel 1 + # lnd-1 -> cln-1 lncli-sim 1 connect $(lightning-cli-sim 1 getinfo | jq -r '.id')@lnbits-legend-clightning-1-1 > /dev/null echo "open channel from lnd-1 to cln-1" @@ -128,6 +136,21 @@ lnbits-lightning-init(){ bitcoin-cli-sim -generate 10 > /dev/null wait-for-lnd-channel 2 + # lnd-3 -> cln-2 + lncli-sim 3 connect $(lightning-cli-sim 2 getinfo | jq -r '.id')@lnbits-legend-clightning-2-1 > /dev/null + echo "open channel from lnd-3 to cln-2" + lncli-sim 3 openchannel $(lightning-cli-sim 2 getinfo | jq -r '.id') $channel_size $balance_size > /dev/null + bitcoin-cli-sim -generate 10 > /dev/null + wait-for-lnd-channel 3 + + # lnd-3 -> cln-1 + lncli-sim 3 connect $(lightning-cli-sim 1 getinfo | jq -r '.id')@lnbits-legend-clightning-1-1 > /dev/null + echo "open channel from lnd-3 to cln-1" + lncli-sim 3 openchannel $(lightning-cli-sim 1 getinfo | jq -r '.id') $channel_size $balance_size > /dev/null + bitcoin-cli-sim -generate 10 > /dev/null + wait-for-lnd-channel 3 + + # cln-1 -> cln-2 peerid=$(connect_clightning_node 1 2) echo "open channel from cln-1 to cln-2" diff --git a/tests b/tests index 3bb0e22..92c1a6e 100755 --- a/tests +++ b/tests @@ -20,7 +20,7 @@ run(){ } failed="false" -blockheight=200 +blockheight=230 utxos=5 channel_size=16000000 # 0.016 btc balance_size=8000000 # 0.08 btc @@ -32,13 +32,16 @@ printf "\033[;1;36mregtest started! starting tests...\033[;0m\n" echo "==================================" echo "" -run "boltz service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:9001/version") -run "mempool service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:8080/") -for i in 1 2; do +for i in 1 2 3; do run "lnd-$i .synced_to_chain" "true" $(lncli-sim $i getinfo | jq -r ".synced_to_chain") run "lnd-$i utxo count" $utxos $(lncli-sim $i listunspent | jq -r ".utxos | length") run "lnd-$i .block_height" $blockheight $(lncli-sim $i getinfo | jq -r ".block_height") - run "lnd-$i openchannels" 2 $(lncli-sim $i listchannels | jq -r ".channels | length") + if [[ "$i" == "2" ]]; then + channel_count=2 + else + channel_count=3 + fi + run "lnd-$i openchannels" $channel_count $(lncli-sim $i listchannels | jq -r ".channels | length") run "lnd-$i .channels[0].active_channel" true $(lncli-sim $i listchannels | jq -r ".channels[0].active") run "lnd-$i .channels[0].capacity" $channel_size $(lncli-sim $i listchannels | jq -r ".channels[0].capacity") run "lnd-$i .channels[0].push_amount_sat" $balance_size $(lncli-sim $i listchannels | jq -r ".channels[0].push_amount_sat") @@ -46,12 +49,16 @@ done for i in 1 2; do run "cln-$i blockheight" $blockheight $(lightning-cli-sim $i getinfo | jq -r ".blockheight") run "cln-$i utxo count" $utxos $(lightning-cli-sim $i listfunds | jq -r ".outputs | length") - run "cln-$i openchannels" 2 $(lightning-cli-sim $i getinfo | jq -r ".num_active_channels") + run "cln-$i openchannels" 3 $(lightning-cli-sim $i getinfo | jq -r ".num_active_channels") run "cln-$i channel[0].state" "CHANNELD_NORMAL" $(lightning-cli-sim $i listfunds | jq -r ".channels[0].state") run "cln-$i channel[0].channel_total_sat" $channel_size $(lightning-cli-sim $i listfunds | jq -r ".channels[0].channel_total_sat") run "cln-$i channel[0].channel_sat" $balance_size $(lightning-cli-sim $i listfunds | jq -r ".channels[0].channel_sat") done +run "boltz service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:9001/version") +run "mempool service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:8080/") +run "lnbits service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:5001/") + # return non-zero exit code if a test fails if [[ "$failed" == "true" ]]; then echo ""