Skip to content
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
41 changes: 41 additions & 0 deletions .github/workflows/nigiri-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,47 @@ jobs:
uses: vulpemventures/nigiri-github-action@v1
with:
use_liquid: false
- name: Wait for Bitcoin RPC
run: |
python3 - <<'PY'
import json
import time
import urllib.error
import urllib.request

url = "http://localhost:18443"
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, url, "admin1", "123")
opener = urllib.request.build_opener(
urllib.request.HTTPBasicAuthHandler(password_mgr)
)
payload = json.dumps({
"jsonrpc": "2.0",
"id": "ci-ready",
"method": "getblockchaininfo",
"params": [],
}).encode()

deadline = time.time() + 120
last_error = None
while time.time() < deadline:
try:
request = urllib.request.Request(
url,
data=payload,
headers={"content-type": "application/json"},
)
with opener.open(request, timeout=5) as response:
result = json.loads(response.read())["result"]
print("Bitcoin RPC ready:", result["chain"], result["blocks"])
raise SystemExit(0)
except Exception as exc:
last_error = exc
print("Waiting for Bitcoin RPC:", exc)
time.sleep(2)

raise SystemExit(f"Bitcoin RPC did not become ready: {last_error}")
PY
- name: Run integration tests
run: |
pytest tests/integration/basics.py
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ test = [
"mock",
"black",
"pre-commit",
"bdkpython"
]
"Werkzeug<3",
"bdkpython==0.32.1"
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
embit>=0.6.1
Flask>=2.1.1
Flask>=2.1.1,<2.3
Flask-SQLAlchemy==2.5.1
sqlalchemy>=1.4.42,<2.0
psycopg2-binary
Expand Down
4 changes: 3 additions & 1 deletion src/cryptoadvance/spectrum/util_specter.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ def trace_call_after(cls, url, payload, timestamp):
def __getattr__(self, method):
def fn(*args, **kwargs):
r = self.multi([(method, *args)], **kwargs)[0]
if r["error"] is not None:
# Bitcoin Core 30.0 omits the JSON-RPC "error" field from successful
# responses instead of returning "error": null.
if r.get("error") is not None:
raise Exception(
f"Request error for method {method}{args}: {r['error']['message']}",
r,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/elsock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def callback(something):
port=50002,
callback=callback,
use_ssl=True,
call_timeout=1,
call_timeout=10,
)
ts = elsock.ping()
logger.info(f"First working ping in {ts} ms")
Expand Down Expand Up @@ -80,7 +80,7 @@ def callback(something):
logger.info(elsock._socket)
ts = elsock.ping()
logger.info(f"second working ping in {ts} ms")
assert ts < 1
assert ts < 10
assert caplog.text.count("ElectrumSocket Status changed") == 9

assert (
Expand Down
Loading