Skip to content

Commit

Permalink
Merge pull request #494 from pinheadmz/semver-bitcoin
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark authored Aug 26, 2024
2 parents 8190180 + c0224db commit 29525cf
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 254 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# test: [scenarios_test.py, rpc_test.py, graph_test.py, ln_test.py, dag_connection_test.py, logging_test.py]
test: [scenarios_test.py, rpc_test.py, dag_connection_test.py, logging_test.py]
test:
- conf_test.py
- dag_connection_test.py
- logging_test.py
- rpc_test.py
- scenarios_test.py
steps:
- uses: actions/checkout@v4
- uses: azure/[email protected]
Expand Down
12 changes: 12 additions & 0 deletions resources/charts/bitcoincore/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


{{/*
Add network section heading in bitcoin.conf after v0.17.0
*/}}
{{- define "bitcoincore.check_semver.regtest" -}}
{{- $tag := .Values.image.tag | trimPrefix "v" -}}
{{- $version := semverCompare ">=0.17.0" $tag -}}
{{- if $version -}}
[regtest]
{{- end -}}
{{- end -}}
3 changes: 3 additions & 0 deletions resources/charts/bitcoincore/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
data:
bitcoin.conf: |
{{- if eq .Values.chain "regtest" }}
regtest=1
{{ template "bitcoincore.check_semver.regtest" . }}
{{- tpl .Values.regtestConfig . | nindent 4 }}
{{- end }}
{{- .Values.baseConfig | nindent 4 }}
Expand Down
3 changes: 0 additions & 3 deletions resources/charts/bitcoincore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ metricsExport: false
prometheusMetricsPort: 9332

regtestConfig: |
regtest=1
[regtest]
rpcuser=user
rpcpassword=password
rpcport=18443
Expand Down
57 changes: 0 additions & 57 deletions test/build_branch_test.py

This file was deleted.

58 changes: 58 additions & 0 deletions test/conf_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3

import json
import os
import re
from pathlib import Path

from test_base import TestBase

from warnet.k8s import get_mission


class ConfTest(TestBase):
def __init__(self):
super().__init__()
self.network_dir = Path(os.path.dirname(__file__)) / "data" / "bitcoin_conf"

def run_test(self):
try:
self.setup_network()
self.check_uacomment()
finally:
self.stop_server()

def setup_network(self):
self.log.info("Setting up network")
self.log.info(self.warcli(f"deploy {self.network_dir}"))
self.wait_for_all_tanks_status(target="running")

def check_uacomment(self):
tanks = get_mission("tank")

def get_uacomment():
for tank in tanks[::-1]:
try:
name = tank.metadata.name
info = json.loads(self.warcli(f"bitcoin rpc {name} getnetworkinfo"))
subver = info["subversion"]

# Regex pattern to match the uacomment inside parentheses
# e.g. /Satoshi:27.0.0(tank-0027)/
pattern = r"\(([^)]+)\)"
match = re.search(pattern, subver)
if match:
uacomment = match.group(1)
assert uacomment == name
else:
return False
except Exception:
return False
return True

self.wait_for_predicate(get_uacomment)


if __name__ == "__main__":
test = ConfTest()
test.run_test()
64 changes: 64 additions & 0 deletions test/data/bitcoin_conf/network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
nodes:
- name: tank-0016
image:
tag: "v0.16.1"
connect:
- tank-0017
config:
uacomment=tank-0016
- name: tank-0017
image:
tag: "v0.17.0"
connect:
- tank-0019
config:
uacomment=tank-0017
- name: tank-0019
image:
tag: "v0.19.2"
connect:
- tank-0020
config:
uacomment=tank-0019
- name: tank-0020
image:
tag: "v0.20.0"
connect:
- tank-0021
config:
uacomment=tank-0020
- name: tank-0021
image:
tag: "v0.21.1"
connect:
- tank-0024
config:
uacomment=tank-0021
- name: tank-0024
image:
tag: "24.2"
connect:
- tank-0025
config:
uacomment=tank-0024
- name: tank-0025
image:
tag: "25.1"
connect:
- tank-0026
config:
uacomment=tank-0025
- name: tank-0026
image:
tag: "26.0"
connect:
- tank-0027
config:
uacomment=tank-0026
- name: tank-0027
image:
tag: "27.0"
connect:
- tank-0016
config:
uacomment=tank-0027
4 changes: 4 additions & 0 deletions test/data/bitcoin_conf/node-defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image:
repository: bitcoindevproject/bitcoin
pullPolicy: IfNotPresent
tag: "27.0"
28 changes: 0 additions & 28 deletions test/data/build_v24_test.graphml

This file was deleted.

93 changes: 0 additions & 93 deletions test/data/permutations.graphml

This file was deleted.

Empty file removed test/data/services.graphml
Empty file.
Empty file removed test/graph_test.py
Empty file.
Loading

0 comments on commit 29525cf

Please sign in to comment.