Skip to content

Commit 29525cf

Browse files
authored
Merge pull request #494 from pinheadmz/semver-bitcoin
2 parents 8190180 + c0224db commit 29525cf

File tree

13 files changed

+147
-254
lines changed

13 files changed

+147
-254
lines changed

.github/workflows/test.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ jobs:
2929
runs-on: ubuntu-latest
3030
strategy:
3131
matrix:
32-
# test: [scenarios_test.py, rpc_test.py, graph_test.py, ln_test.py, dag_connection_test.py, logging_test.py]
33-
test: [scenarios_test.py, rpc_test.py, dag_connection_test.py, logging_test.py]
32+
test:
33+
- conf_test.py
34+
- dag_connection_test.py
35+
- logging_test.py
36+
- rpc_test.py
37+
- scenarios_test.py
3438
steps:
3539
- uses: actions/checkout@v4
3640
- uses: azure/[email protected]

resources/charts/bitcoincore/templates/_helpers.tpl

+12
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,15 @@ Create the name of the service account to use
5555
{{- default "default" .Values.serviceAccount.name }}
5656
{{- end }}
5757
{{- end }}
58+
59+
60+
{{/*
61+
Add network section heading in bitcoin.conf after v0.17.0
62+
*/}}
63+
{{- define "bitcoincore.check_semver.regtest" -}}
64+
{{- $tag := .Values.image.tag | trimPrefix "v" -}}
65+
{{- $version := semverCompare ">=0.17.0" $tag -}}
66+
{{- if $version -}}
67+
[regtest]
68+
{{- end -}}
69+
{{- end -}}

resources/charts/bitcoincore/templates/configmap.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ metadata:
77
data:
88
bitcoin.conf: |
99
{{- if eq .Values.chain "regtest" }}
10+
regtest=1
11+
12+
{{ template "bitcoincore.check_semver.regtest" . }}
1013
{{- tpl .Values.regtestConfig . | nindent 4 }}
1114
{{- end }}
1215
{{- .Values.baseConfig | nindent 4 }}

resources/charts/bitcoincore/values.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ metricsExport: false
111111
prometheusMetricsPort: 9332
112112

113113
regtestConfig: |
114-
regtest=1
115-
116-
[regtest]
117114
rpcuser=user
118115
rpcpassword=password
119116
rpcport=18443

test/build_branch_test.py

-57
This file was deleted.

test/conf_test.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
import os
5+
import re
6+
from pathlib import Path
7+
8+
from test_base import TestBase
9+
10+
from warnet.k8s import get_mission
11+
12+
13+
class ConfTest(TestBase):
14+
def __init__(self):
15+
super().__init__()
16+
self.network_dir = Path(os.path.dirname(__file__)) / "data" / "bitcoin_conf"
17+
18+
def run_test(self):
19+
try:
20+
self.setup_network()
21+
self.check_uacomment()
22+
finally:
23+
self.stop_server()
24+
25+
def setup_network(self):
26+
self.log.info("Setting up network")
27+
self.log.info(self.warcli(f"deploy {self.network_dir}"))
28+
self.wait_for_all_tanks_status(target="running")
29+
30+
def check_uacomment(self):
31+
tanks = get_mission("tank")
32+
33+
def get_uacomment():
34+
for tank in tanks[::-1]:
35+
try:
36+
name = tank.metadata.name
37+
info = json.loads(self.warcli(f"bitcoin rpc {name} getnetworkinfo"))
38+
subver = info["subversion"]
39+
40+
# Regex pattern to match the uacomment inside parentheses
41+
# e.g. /Satoshi:27.0.0(tank-0027)/
42+
pattern = r"\(([^)]+)\)"
43+
match = re.search(pattern, subver)
44+
if match:
45+
uacomment = match.group(1)
46+
assert uacomment == name
47+
else:
48+
return False
49+
except Exception:
50+
return False
51+
return True
52+
53+
self.wait_for_predicate(get_uacomment)
54+
55+
56+
if __name__ == "__main__":
57+
test = ConfTest()
58+
test.run_test()

test/data/bitcoin_conf/network.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
nodes:
2+
- name: tank-0016
3+
image:
4+
tag: "v0.16.1"
5+
connect:
6+
- tank-0017
7+
config:
8+
uacomment=tank-0016
9+
- name: tank-0017
10+
image:
11+
tag: "v0.17.0"
12+
connect:
13+
- tank-0019
14+
config:
15+
uacomment=tank-0017
16+
- name: tank-0019
17+
image:
18+
tag: "v0.19.2"
19+
connect:
20+
- tank-0020
21+
config:
22+
uacomment=tank-0019
23+
- name: tank-0020
24+
image:
25+
tag: "v0.20.0"
26+
connect:
27+
- tank-0021
28+
config:
29+
uacomment=tank-0020
30+
- name: tank-0021
31+
image:
32+
tag: "v0.21.1"
33+
connect:
34+
- tank-0024
35+
config:
36+
uacomment=tank-0021
37+
- name: tank-0024
38+
image:
39+
tag: "24.2"
40+
connect:
41+
- tank-0025
42+
config:
43+
uacomment=tank-0024
44+
- name: tank-0025
45+
image:
46+
tag: "25.1"
47+
connect:
48+
- tank-0026
49+
config:
50+
uacomment=tank-0025
51+
- name: tank-0026
52+
image:
53+
tag: "26.0"
54+
connect:
55+
- tank-0027
56+
config:
57+
uacomment=tank-0026
58+
- name: tank-0027
59+
image:
60+
tag: "27.0"
61+
connect:
62+
- tank-0016
63+
config:
64+
uacomment=tank-0027
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
image:
2+
repository: bitcoindevproject/bitcoin
3+
pullPolicy: IfNotPresent
4+
tag: "27.0"

test/data/build_v24_test.graphml

-28
This file was deleted.

test/data/permutations.graphml

-93
This file was deleted.

test/data/services.graphml

Whitespace-only changes.

test/graph_test.py

Whitespace-only changes.

0 commit comments

Comments
 (0)