Skip to content

Commit

Permalink
fixup merge
Browse files Browse the repository at this point in the history
fixup readme
  • Loading branch information
dni committed Jul 26, 2024
1 parent b9fbcbf commit f9f5ca4
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 91 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ jobs:
- uses: actions/checkout@v2
- name: Run tests
run: |
chmod +x ./regtest
./regtest
git clone https://github.com/lnbits/lnbits
docker build -t lnbits/lnbits lnbits
chmod +x ./start-regtest
./start-regtest
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
![TESTS](https://github.com/BoltzExchange/legend-regtest-enviroment/actions/workflows/ci.yml/badge.svg)
![TESTS](https://github.com/lnbits/legend-regtest-enviroment/actions/workflows/ci.yml/badge.svg)

# nodes
* lnd-1: for locally testing
* lnd-1: for locally testing your current lnbits
* lnd-2: used for boltz backend
* cln-1: for locally testing
* lnd-3: used for lnbits inside docker
* cln-1: for locally testing your current lnbits
* cln-2: used for clightning-REST
* eclair-1: for locally testing your current lnbits

# Installing regtest
get the regtest enviroment ready
Expand Down Expand Up @@ -62,9 +65,6 @@ source docker-scripts.sh
# use bitcoin core, mine a block
bitcoin-cli-sim -generate 1

# use elements, mine a liquid block
bitcoin-cli-sim -generate 1

# use c-lightning nodes
lightning-cli-sim 1 newaddr | jq -r '.bech32' # use node 1
lightning-cli-sim 2 getinfo # use node 2
Expand All @@ -78,6 +78,7 @@ lncli-sim 2 listpeers
# urls
* boltz api: http://localhost:9001/
* lnd-1 rest: http://localhost:8081/
* lnbits: http://localhost:5001/

# debugging docker logs
```sh
Expand Down
30 changes: 0 additions & 30 deletions data/boltz/boltz.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ minSwapAmount = 10_000
swapMaximal = 1050
swapTaproot = 300

[[pairs]]
base = "RBTC"
quote = "BTC"
rate = 1
fee = 0.5

maxSwapAmount = 4_294_967
minSwapAmount = 10_000

[pairs.timeoutDelta]
reverse = 1440
swapMinimal = 1000
swapMaximal = 1050
swapTaproot = 1440

[[currencies]]
symbol = "BTC"
network = "bitcoinRegtest"
Expand Down Expand Up @@ -98,18 +83,3 @@ maxZeroConfAmount = 40_294_967
cookie = "/root/.elements/liquid.cookie"
zmqpubrawtx = "tcp://elementsd:31000"
zmqpubhashblock = "tcp://elementsd:31002"


[rsk]
providerEndpoint = "http://anvil:8545"

etherSwapAddress = "0x5fbdb2315678afecb367f032d93f642f64180aa3"
erc20SwapAddress = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512"

[[rsk.tokens]]
symbol = "RBTC"

maxSwapAmount = 4_294_96700
minSwapAmount = 10000

minWalletBalance = 100_000_000
88 changes: 59 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
bitcoind:
hostname: bitcoind
restart: always
image: boltz/bitcoin-core:24.0.1
image: boltz/bitcoin-core:27.1
command:
- -regtest
- -fallbackfee=0.00000253
Expand All @@ -34,6 +34,13 @@ services:
- -txindex
- -rpcallowip=0.0.0.0/0
- -rpcbind=0.0.0.0
# eclair
# - -rpcuser=lnbits
# - -rpcpassword=lnbits
# - -dbcache=2048
# - -rpcworkqueue=128
# - -rpcclienttimeout=30

expose:
- 18444
ports:
Expand All @@ -57,6 +64,8 @@ services:
- 18884:18884
volumes:
- ./data/elements/elements.conf:/home/elements/.elements/elements.conf
volumes_from:
- bitcoind:ro

clightning-1:
hostname: clightning-1
Expand Down Expand Up @@ -87,17 +96,28 @@ services:

clightning-2:
hostname: clightning-2
restart: always
depends_on:
- bitcoind
image: boltz/c-lightning:22.11.1
entrypoint: "sh -c 'sleep 15 && lightningd --large-channels --network regtest --grpc-port 9737 --bind-addr=0.0.0.0:9735 --bitcoin-rpcconnect=bitcoind --bitcoin-rpcport=18443 --bitcoin-rpcuser=lnbits --bitcoin-rpcpassword=lnbits'"
image: boltz/c-lightning:23.08.1
command:
- --large-channels
- --network
- regtest
- --bind-addr=0.0.0.0:9735
- --bitcoin-rpcconnect=bitcoind
- --bitcoin-rpcport=18443
- --grpc-port=9736
- --dev-bitcoind-poll=3
- --dev-fast-gossip
- --experimental-offers
- --experimental-dual-fund
expose:
- 9735
ports:
- 9737:9737
- 9736
volumes:
- ./data/clightning-2:/root/.lightning/
volumes_from:
- bitcoind:ro

clightning-2-rest:
hostname: clightning-2-rest
Expand Down Expand Up @@ -134,7 +154,7 @@ services:
- 9735
- 9736
volumes:
- ./data/clightning-2:/root/.lightning/
- ./data/clightning-3:/root/.lightning/
volumes_from:
- bitcoind:ro

Expand Down Expand Up @@ -191,42 +211,54 @@ services:
expose:
- 8081
- 9735
ports:
- 11009:10009
- 10009
volumes:
- ./data/lnd-2:/root/.lnd/
volumes_from:
- bitcoind:ro

lnd-3:
hostname: lnd-3
depends_on:
- bitcoind
image: boltz/lnd:0.17.4-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'"
ports:
- 8081:8081
- 10009:10009
command:
- --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.rpccookie=/root/.bitcoin/regtest/.cookie
- --noseedbackup
- --protocol.wumbo-channels
expose:
- 8081
- 9735
- 10009
volumes:
- ./data/lnd-3:/root/.lnd/
volumes_from:
- bitcoind:ro

eclair:
hostname: eclair
depends_on:
- bitcoind
image: boltz/eclair:0.8.0
restart: on-failure
entrypoint: "sh -c 'JAVA_OPTS=-Xmx512m /eclair-node/bin/eclair-node.sh -Declair.datadir=/root/eclair -Declair.printToConsole'"
ports:
- 8082:8080
expose:
- 9735
- 8080
volumes:
- ./data/eclair:/root/eclair
# eclair:
# hostname: eclair
# depends_on:
# - bitcoind
# image: boltz/eclair:0.8.0
# restart: on-failure
# entrypoint: "sh -c 'JAVA_OPTS=-Xmx512m /eclair-node/bin/eclair-node.sh -Declair.datadir=/root/eclair -Declair.printToConsole'"
# ports:
# - 8082:8080
# expose:
# - 9735
# - 8080
# volumes:
# - ./data/eclair:/root/eclair

boltz:
hostname: boltz
Expand Down Expand Up @@ -325,5 +357,3 @@ services:

volumes:
lnbits-data:
volumes_from:
- bitcoind:ro
39 changes: 23 additions & 16 deletions docker-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ regtest-start-log(){
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 ./data/elements/liquidregtest ./data/bitcoin/regtest
sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/boltz/boltz.db ./data/elements/liquidregtest ./data/bitcoin/regtest
# 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/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3
}

regtest-restart(){
Expand Down Expand Up @@ -159,23 +159,29 @@ elements-init(){
}

boltz-client-init(){
boltzcli-sim wallet create lnbits LBTC
echo "boltz-client-init..."
# boltzcli-sim wallet create lnbits LBTC
# boltzcli-sim formatmacaroon
}

lightning-sync(){
wait-for-clightning-sync 1
wait-for-clightning-sync 2
wait-for-clightning-sync 3
wait-for-lnd-sync 1
wait-for-lnd-sync 2
wait-for-lnd-sync 3
}

lightning-init(){
# create 10 UTXOs for each node
for i in 0 1 2; do
fund_clightning_node 1
fund_clightning_node 2
fund_clightning_node 3
fund_lnd_node 1
fund_lnd_node 2
fund_lnd_node 3
done

echo "mining 3 blocks..."
Expand Down Expand Up @@ -246,24 +252,25 @@ lightning-init(){
bitcoin-cli-sim -generate $channel_confirms > /dev/null
wait-for-lnd-channel 3

# lnd-1 -> eclair-1
lncli-sim 1 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null
echo "open channel from lnd-2 to eclair-1"
lncli-sim 1 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null
bitcoin-cli-sim -generate $channel_confirms > /dev/null
wait-for-lnd-channel 1
# # lnd-1 -> eclair-1
# lncli-sim 1 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null
# echo "open channel from lnd-2 to eclair-1"
# lncli-sim 1 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null
# bitcoin-cli-sim -generate $channel_confirms > /dev/null
# wait-for-lnd-channel 1

# lnd-2 -> eclair-1
lncli-sim 2 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null
echo "open channel from lnd-2 to eclair-1"
lncli-sim 2 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null
bitcoin-cli-sim -generate $channel_confirms > /dev/null
wait-for-lnd-channel 2
# # lnd-2 -> eclair-1
# lncli-sim 2 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null
# echo "open channel from lnd-2 to eclair-1"
# lncli-sim 2 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null
# bitcoin-cli-sim -generate $channel_confirms > /dev/null
# wait-for-lnd-channel 2

wait-for-clightning-channel 1
wait-for-clightning-channel 2
wait-for-clightning-channel 3

wait-for-eclair-channel
# wait-for-eclair-channel

lightning-sync
}
Expand Down
26 changes: 18 additions & 8 deletions regtest → start-regtest
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ run(){
}

failed="false"
blockheight=183
channel_count=3
utxos=5
blockheight=201
utxos=3
channel_size=24000000 # 0.024 btc
balance_size=12000000 # 0.012 btc

Expand All @@ -33,24 +32,35 @@ printf "\033[;1;36mregtest started! starting tests...\033[;0m\n"
echo "=================================="
echo ""


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")
if [[ "$i" == "1" ]]; then
channel_count=5
fi
if [[ "$i" == "2" ]]; then
channel_count=2
fi
if [[ "$i" == "3" ]]; then
channel_count=3
fi
run "lnd-$i openchannels" $channel_count $(lncli-sim $i listchannels | jq -r ".channels | length")
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")
done
for i in 1 2; do
for i in 1 2 3; 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 channel[0].state" "CHANNELD_NORMAL" $(lightning-cli-sim $i listfunds | jq -r ".channels[0].state")
run "cln-$i channel[0].amount_msat" $((channel_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].amount_msat")
run "cln-$i channel[0].our_amount_msat" $((balance_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].our_amount_msat")
run "cln-$i channel[0].amount_msat" $(($channel_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].amount_msat" | sed 's/msat//g')
run "cln-$i channel[0].our_amount_msat" $(($balance_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].our_amount_msat" | sed 's/msat//g')
done

# run "eclair-1 openchannels" 2 $(docker exec lnbits-eclair-1 curl -s http://localhost:8080/channels -X POST -u :lnbits| jq '. | length')
# run "eclair-1 blockHeight" $blockheight $(docker exec lnbits-eclair-1 curl -s http://localhost:8080/getinfo -X POST -u :lnbits| jq '.blockHeight')
run "lnbits service status" "200" $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:5001/")
run "boltz service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:9001/version")

# return non-zero exit code if a test fails
Expand Down

0 comments on commit f9f5ca4

Please sign in to comment.