Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stability tests (multiple consecutive payments to same offer) #30

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/lnd/lnd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protocol.wumbo-channels=true
protocol.custom-message=513
protocol.custom-nodeann=39
protocol.custom-init=39
protocol.wumbo-channels=true

[gossip]
gossip.sub-batch-delay=1s
6 changes: 3 additions & 3 deletions docker/lndk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
FROM rust:1.78-bookworm AS builder

# References for lndk
# https://github.com/lndk-org/lndk/pull/121
ARG LNDK_REF=ae7832730f36ab497ccf5ce5c3d949e42ad9b91c
ARG LNDK_SOURCE=https://github.com/orbitalturtle/lndk.git
ARG LNDK_REF=b8174e191607406fd335483b892e2bd3693a25de

# Add utils
RUN apt-get update \
Expand All @@ -18,7 +18,7 @@ RUN apt-get update \
WORKDIR /usr/src

# Grab and install the latest version of lndk
RUN git clone https://github.com/orbitalturtle/lndk.git . \
RUN git clone ${LNDK_SOURCE} . \
&& git reset --hard ${LNDK_REF} \
&& cargo build --release

Expand Down
18 changes: 9 additions & 9 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,52 +237,52 @@ openChannel() {
# Open a channel between lnd1 and cln1.
echo "Opening channel between lnd1 and cln1"
waitFor lnd1 connect $CLN1_NODE_URI
waitFor lnd1 openchannel $CLN1_PUBKEY 10000000 5000000
waitFor lnd1 openchannel $CLN1_PUBKEY 15000000 7500000

# Open a channel between lnd1 and eclair1.
echo "Opening channel between lnd1 and eclair1"
waitFor lnd1 connect $ECLAIR1_NODE_URI
waitFor lnd1 openchannel $ECLAIR1_PUBKEY 10000000 5000000
waitFor lnd1 openchannel $ECLAIR1_PUBKEY 15000000 7500000

# Open a channel between lnd1 and ldknode1.
echo "Opening channel between lnd1 and ldknode1"
waitFor lnd1 connect $LDKNODE1_NODE_URI
waitFor lnd1 openchannel $LDKNODE1_PUBKEY 10000000 5000000
waitFor lnd1 openchannel $LDKNODE1_PUBKEY 15000000 7500000



# Open a channel between lnd1 and lnd2.
echo "Opening channel between lnd1 and lnd2"
waitFor lnd1 connect $LND2_NODE_URI
waitFor lnd1 openchannel $LND2_PUBKEY 10000000 5000000
waitFor lnd1 openchannel $LND2_PUBKEY 15000000 7500000



# Open a channel between lnd2 and cln2.
echo "Opening channel between lnd2 and cln2"
waitFor lnd2 connect $CLN2_NODE_URI
waitFor lnd2 openchannel $CLN2_PUBKEY 10000000 5000000
waitFor lnd2 openchannel $CLN2_PUBKEY 15000000 7500000

# Open a channel between lnd2 and eclair2.
echo "Opening channel between lnd2 and eclair2"
waitFor lnd2 connect $ECLAIR2_NODE_URI
waitFor lnd2 openchannel $ECLAIR2_PUBKEY 10000000 5000000
waitFor lnd2 openchannel $ECLAIR2_PUBKEY 15000000 7500000

# Open a channel between lnd2 and ldknode2.
echo "Opening channel between lnd2 and ldknode2"
waitFor lnd2 connect $LDKNODE2_NODE_URI
waitFor lnd2 openchannel $LDKNODE2_PUBKEY 10000000 5000000
waitFor lnd2 openchannel $LDKNODE2_PUBKEY 15000000 7500000


# Open a channel between cln2 and cln3.
echo "Opening channel between cln2 and cln3"
waitFor cln2 connect id=$CLN3_NODE_URI
waitFor cln2 fundchannel id=$CLN3_PUBKEY amount=10000000 push_msat=5000000
waitFor cln2 fundchannel id=$CLN3_PUBKEY amount=15000000 push_msat=7500000

# Open a channel between eclair2 and eclair3.
echo "Opening channel between eclair2 and eclair3"
waitFor eclair2 connect --uri=$ECLAIR3_NODE_URI
waitFor eclair2 open --nodeId=$ECLAIR3_PUBKEY --fundingSatoshis=10000000 --pushMsat5000000
waitFor eclair2 open --nodeId=$ECLAIR3_PUBKEY --fundingSatoshis=15000000 --pushMsat=7500000

# Generate some blocks to confirm the channel.
mineBlocks $BITCOIN_ADDRESS 10
Expand Down
51 changes: 51 additions & 0 deletions test/test04_payments_ldknode_stability.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bats

# set -eo pipefail
# set -x

setup() {
load 'test_helper/common-setup'
_common_setup

source "$PROJECT_ROOT/test/functions.sh"

TEST_COUNT=10
SUCCESS_COUNT=0
}

increment_success_count() {
(( ++SUCCESS_COUNT ))
}

print_success_count() {
echo "$SUCCESS_COUNT"
}

get_offer() {
OFFER=$(generate_offer_ldknode 'ldknode2')
}

print_offer() {
echo $OFFER
}

attempt() {
$PROJECT_ROOT/bin/lndk-cli lndk1 pay-offer $OFFER 5000000
}

@test "Multiple consecutive payments to LDK Node (lnd1 -> lnd2 -> ldknode2) x 10" {

get_offer
run print_offer

for i in $(seq 1 $TEST_COUNT)
do
run attempt
if [[ "${lines[0]}" =~ "Successfully paid for offer!" ]]; then
increment_success_count
fi
done

run print_success_count
assert_equal $SUCCESS_COUNT $TEST_COUNT
}