Skip to content

Commit c9c844d

Browse files
committed
btcpayserver: add tests
1 parent f93c3c8 commit c9c844d

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ env:
2727
- PKG=elementsd STABLE=0
2828
- PKG=electrs STABLE=1
2929
- PKG=electrs STABLE=0
30+
- PKG=nbxplorer STABLE=1
31+
- PKG=nbxplorer STABLE=0
32+
- PKG=btcpayserver STABLE=1
33+
- PKG=btcpayserver STABLE=0
3034
- PKG=liquid-swap STABLE=1
3135
- PKG=lightning-loop STABLE=0
3236
- PKG=nixops19_09 STABLE=1

test/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ def run_tests(extra_tests):
8484
)
8585
)
8686

87+
assert_running("nbxplorer")
88+
machine.wait_until_succeeds(log_has_string("nbxplorer", "BTC: RPC connection successful"))
89+
extra_tests.pop("nbxplorer")()
90+
assert_running("btcpayserver")
91+
machine.wait_until_succeeds(log_has_string("btcpayserver", "Listening on"))
92+
extra_tests.pop("btcpayserver")()
93+
8794
assert_running("spark-wallet")
8895
extra_tests.pop("spark-wallet")()
8996

test/scenarios/default.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ def electrs():
22
machine.wait_for_open_port(4224) # prometeus metrics provider
33

44

5+
def nbxplorer():
6+
machine.wait_for_open_port(24444)
7+
8+
9+
def btcpayserver():
10+
machine.wait_for_open_port(23000)
11+
# test lnd custom macaroon
12+
assert_matches(
13+
'sudo -u btcpayserver curl -s --cacert /secrets/lnd-cert --header "Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 /run/lnd/btcpayserver.macaroon)" -X GET https://127.0.0.1:8080/v1/getinfo | jq',
14+
'"version"',
15+
)
16+
17+
518
def spark_wallet():
619
machine.wait_for_open_port(9737)
720
spark_auth = re.search("login=(.*)", succeed("cat /secrets/spark-wallet-login"))[1]
@@ -31,6 +44,8 @@ def prestop():
3144

3245
extra_tests = {
3346
"electrs": electrs,
47+
"nbxplorer": nbxplorer,
48+
"btcpayserver": btcpayserver,
3449
"spark-wallet": spark_wallet,
3550
"lightning-charge": lightning_charge,
3651
"nanopos": nanopos,

test/scenarios/withnetns.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
recurringdonations_ip = "169.254.1.20"
1111
nginx_ip = "169.254.1.21"
1212
lightningloop_ip = "169.254.1.22"
13+
nbxplorer_ip = "169.254.1.23"
14+
btcpayserver_ip = "169.254.1.24"
1315

1416

1517
def electrs():
@@ -18,6 +20,20 @@ def electrs():
1820
) # prometeus metrics provider
1921

2022

23+
def nbxplorer():
24+
machine.wait_until_succeeds("ip netns exec nb-nbxplorer nc -z %s 24444" % nbxplorer_ip)
25+
26+
27+
def btcpayserver():
28+
machine.wait_until_succeeds("ip netns exec nb-btcpayserver nc -z %s 23000" % btcpayserver_ip)
29+
# test lnd custom macaroon
30+
assert_matches(
31+
'ip netns exec nb-btcpayserver sudo -u btcpayserver curl -s --cacert /secrets/lnd-cert --header "Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 /run/lnd/btcpayserver.macaroon)" -X GET https://%s:8080/v1/getinfo | jq'
32+
% lnd_ip,
33+
'"version"',
34+
)
35+
36+
2137
def spark_wallet():
2238
machine.wait_until_succeeds("ip netns exec nb-spark-wallet nc -z %s 9737" % sparkwallet_ip)
2339
spark_auth = re.search("login=(.*)", succeed("cat /secrets/spark-wallet-login"))[1]
@@ -50,13 +66,16 @@ def web_index():
5066
def prestop():
5167
ping_bitcoind = "ip netns exec nb-bitcoind ping -c 1 -w 1"
5268
ping_nanopos = "ip netns exec nb-nanopos ping -c 1 -w 1"
69+
ping_nbxplorer = "ip netns exec nb-nbxplorer ping -c 1 -w 1"
5370

5471
# Positive ping tests (non-exhaustive)
5572
machine.succeed(
5673
"%s %s &&" % (ping_bitcoind, bitcoind_ip)
5774
+ "%s %s &&" % (ping_bitcoind, clightning_ip)
5875
+ "%s %s &&" % (ping_bitcoind, lnd_ip)
5976
+ "%s %s &&" % (ping_bitcoind, liquidd_ip)
77+
+ "%s %s &&" % (ping_bitcoind, nbxplorer_ip)
78+
+ "%s %s &&" % (ping_nbxplorer, btcpayserver_ip)
6079
+ "%s %s &&" % (ping_nanopos, lightningcharge_ip)
6180
+ "%s %s &&" % (ping_nanopos, nanopos_ip)
6281
+ "%s %s" % (ping_nanopos, nginx_ip)
@@ -77,7 +96,8 @@ def prestop():
7796
+ "%s %s ||" % (ping_nanopos, liquidd_ip)
7897
+ "%s %s ||" % (ping_nanopos, electrs_ip)
7998
+ "%s %s ||" % (ping_nanopos, sparkwallet_ip)
80-
+ "%s %s" % (ping_nanopos, recurringdonations_ip)
99+
+ "%s %s ||" % (ping_nanopos, recurringdonations_ip)
100+
+ "%s %s" % (ping_nanopos, btcpayserver_ip)
81101
)
82102

83103
# test that netns-exec can't be run for unauthorized namespace
@@ -94,6 +114,8 @@ def prestop():
94114

95115
extra_tests = {
96116
"electrs": electrs,
117+
"nbxplorer": nbxplorer,
118+
"btcpayserver": btcpayserver,
97119
"spark-wallet": spark_wallet,
98120
"lightning-charge": lightning_charge,
99121
"nanopos": nanopos,

test/test.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ import ./make-test.nix rec {
5252

5353
services.backups.enable = true;
5454

55+
services.btcpayserver.enable = true;
56+
services.btcpayserver.lightningBackend = "lnd";
57+
# needed to test macaroon creation
58+
environment.systemPackages = with pkgs; [ openssl xxd ];
59+
5560
# to test that unused secrets are made inaccessible by 'setup-secrets'
5661
systemd.services.generate-secrets.postStart = ''
5762
install -o nobody -g nogroup -m777 <(:) /secrets/dummy

0 commit comments

Comments
 (0)