-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for multiple consecutive payments
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $TEST_COUNT)" { | ||
|
||
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 | ||
} |