From f6decde5ff364cccfdc7b5ba7c9e20a38fadd30d Mon Sep 17 00:00:00 2001 From: daywalker90 <8257956+daywalker90@users.noreply.github.com> Date: Sat, 8 Jun 2024 12:16:34 +0200 Subject: [PATCH] modernize cln tests and CI --- .github/workflows/build.yaml | 6 +++++- .github/workflows/cln-plugin.yaml | 16 ++++++++++------ watchtower-plugin/src/retrier.rs | 4 ++-- watchtower-plugin/tests/conftest.py | 15 +-------------- watchtower-plugin/tests/pyproject.toml | 4 ++-- watchtower-plugin/tests/test.py | 24 +++++++++++++----------- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5eba8011..27801560 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,10 @@ name: Continuous Integration Checks -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: jobs: build: diff --git a/.github/workflows/cln-plugin.yaml b/.github/workflows/cln-plugin.yaml index b09064d4..4933975a 100644 --- a/.github/workflows/cln-plugin.yaml +++ b/.github/workflows/cln-plugin.yaml @@ -1,10 +1,14 @@ name: CI tests for CLN watchtower-plugin -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: env: - bitcoind_version: 0.20.1 - cln_version: 0.12.1 + bitcoind_version: "27.0" + cln_version: "24.02.2" jobs: cache-cln: @@ -28,10 +32,10 @@ jobs: PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring if: ${{ steps.cache-cln.outputs.cache-hit != 'true' }} run: | - sudo apt-get update && sudo apt-get install gettext + sudo apt-get update && sudo apt-get install -y gettext protobuf-compiler git clone https://github.com/ElementsProject/lightning.git && cd lightning && git checkout v${{ env.cln_version }} pip install --user poetry && poetry install - ./configure --enable-developer && poetry run make + ./configure && poetry run make cln-plugin: needs: cache-cln @@ -69,4 +73,4 @@ jobs: - name: Run tests run: | cd watchtower-plugin/tests - DEVELOPER=1 SLOW_MACHINE=1 poetry run pytest test.py --log-cli-level=INFO -s + VALGRIND=0 SLOW_MACHINE=1 poetry run pytest test.py --log-cli-level=INFO -s diff --git a/watchtower-plugin/src/retrier.rs b/watchtower-plugin/src/retrier.rs index 0920e366..eaf79e6e 100644 --- a/watchtower-plugin/src/retrier.rs +++ b/watchtower-plugin/src/retrier.rs @@ -103,7 +103,7 @@ impl RetryManager { } else if let Some(retrier) = self.retriers.get(&tower_id) { if retrier.is_idle() { if !data.is_none() { - log::error!("Data was send to an idle retier. This should have never happened. Please report! ({data:?})"); + log::error!("Data was send to an idle retrier. This should have never happened. Please report! ({data:?})"); continue; } log::info!( @@ -774,7 +774,7 @@ mod tests { .unwrap() .is_running()); - // Wait until the task gives up and check again (this gives up due to accumulation of transient errors, so the retiers will be idle). + // Wait until the task gives up and check again (this gives up due to accumulation of transient errors, so the retriers will be idle). wait_until!(wt_client .lock() .unwrap() diff --git a/watchtower-plugin/tests/conftest.py b/watchtower-plugin/tests/conftest.py index eb03b751..7a7be943 100644 --- a/watchtower-plugin/tests/conftest.py +++ b/watchtower-plugin/tests/conftest.py @@ -2,7 +2,7 @@ import subprocess from pyln.testing.fixtures import * # noqa: F401,F403 -from pyln.testing.utils import DEVELOPER, BITCOIND_CONFIG, TailableProc +from pyln.testing.utils import BITCOIND_CONFIG, TailableProc WT_PLUGIN = Path("~/.cargo/bin/watchtower-client").expanduser() TEOSD_CONFIG = { @@ -116,19 +116,6 @@ def pytest_runtest_makereport(item, call): setattr(item, "rep_" + rep.when, rep) -def pytest_configure(config): - config.addinivalue_line("markers", "developer: only run when developer is flagged on") - - -def pytest_runtest_setup(item): - for mark in item.iter_markers(name="developer"): - if not DEVELOPER: - if len(mark.args): - pytest.skip("!DEVELOPER: {}".format(mark.args[0])) - else: - pytest.skip("!DEVELOPER: Requires DEVELOPER=1") - - @pytest.fixture(scope="function", autouse=True) def log_name(request): # Here logging is used, you can use whatever you want to use for logs diff --git a/watchtower-plugin/tests/pyproject.toml b/watchtower-plugin/tests/pyproject.toml index abcb2e4a..f11efae3 100644 --- a/watchtower-plugin/tests/pyproject.toml +++ b/watchtower-plugin/tests/pyproject.toml @@ -12,8 +12,8 @@ black = "^22.6.0" [tool.poetry.dev-dependencies] pytest = "^7.1.2" pytest-timeout = "^2.1.0" -pyln-testing = "^0.12.1" -pyln-client = "^23.11" +pyln-testing = "^24.2.1" +pyln-client = "^24.2.1" [build-system] diff --git a/watchtower-plugin/tests/test.py b/watchtower-plugin/tests/test.py index 2066d1b0..7b4657c0 100644 --- a/watchtower-plugin/tests/test.py +++ b/watchtower-plugin/tests/test.py @@ -1,5 +1,4 @@ import pytest -from pyln.client import RpcError from conftest import WT_PLUGIN @@ -16,7 +15,6 @@ def change_endianness(x): return b[::-1].hex() -@pytest.mark.developer("Requires dev_sign_last_tx") def test_watchtower(node_factory, bitcoind, teosd): """ Test watchtower hook. @@ -27,7 +25,13 @@ def test_watchtower(node_factory, bitcoind, teosd): commitment transaction. """ - l1, l2 = node_factory.line_graph(2, opts=[{"allow_broken_log": True}, {"plugin": WT_PLUGIN}]) + l1, l2 = node_factory.line_graph( + 2, + opts=[ + {"broken_log": r"Could not find resolution for output [0-9]?: did \*we\* cheat\?"}, + {"plugin": WT_PLUGIN}, + ], + ) # We need to register l2 with the tower tower_id = teosd.cli.gettowerinfo()["tower_id"] @@ -60,7 +64,7 @@ def test_watchtower(node_factory, bitcoind, teosd): penalty_txid = bitcoind.rpc.getrawmempool()[0] # The channel still exists between the two peers, but it's on chain - assert l1.rpc.listpeers()["peers"][0]["channels"][0]["state"] == "ONCHAIN" + assert l1.rpc.listpeerchannels()["channels"][0]["state"] == "ONCHAIN" assert l2.rpc.getappointment(tower_id, locator)["status"] == "dispute_responded" # Generate blocks until the penalty gets irrevocably resolved @@ -90,7 +94,6 @@ def test_unreachable_watchtower(node_factory, bitcoind, teosd): {}, { "plugin": WT_PLUGIN, - "allow_broken_log": True, "dev-watchtower-max-retry-interval": max_interval_time, }, ], @@ -123,7 +126,7 @@ def test_auto_retry_watchtower(node_factory, bitcoind, teosd): {}, { "plugin": WT_PLUGIN, - "allow_broken_log": True, + "broken_log": r"plugin-watchtower-client: Data was send to an idle retrier. This should have never happened. Please report!.*", "watchtower-max-retry-time": 1, "watchtower-auto-retry-delay": 1, }, @@ -141,7 +144,7 @@ def test_auto_retry_watchtower(node_factory, bitcoind, teosd): l1.rpc.pay(l2.rpc.invoice(25000000, "lbl1", "desc1")["bolt11"]) # Wait until the tower has been flagged as unreachable - l2.daemon.wait_for_log(f"Starting to idle") + l2.daemon.wait_for_log("Starting to idle") assert l2.rpc.gettowerinfo(tower_id)["status"] == "unreachable" assert l2.rpc.gettowerinfo(tower_id)["pending_appointments"] @@ -161,7 +164,6 @@ def test_manually_retry_watchtower(node_factory, bitcoind, teosd): {}, { "plugin": WT_PLUGIN, - "allow_broken_log": True, "watchtower-max-retry-time": 0, }, ], @@ -178,7 +180,7 @@ def test_manually_retry_watchtower(node_factory, bitcoind, teosd): l1.rpc.pay(l2.rpc.invoice(25000000, "lbl1", "desc1")["bolt11"]) # Wait until the tower has been flagged as unreachable - l2.daemon.wait_for_log(f"Starting to idle") + l2.daemon.wait_for_log("Starting to idle") assert l2.rpc.gettowerinfo(tower_id)["status"] == "unreachable" assert l2.rpc.gettowerinfo(tower_id)["pending_appointments"] @@ -193,7 +195,7 @@ def test_manually_retry_watchtower(node_factory, bitcoind, teosd): def test_misbehaving_watchtower(node_factory, bitcoind, teosd, directory): - l1, l2 = node_factory.line_graph(2, opts=[{}, {"plugin": WT_PLUGIN, "allow_broken_log": True}]) + l1, l2 = node_factory.line_graph(2, opts=[{}, {"plugin": WT_PLUGIN}]) # We need to register l2 with the tower tower_id = teosd.cli.gettowerinfo()["tower_id"] @@ -210,7 +212,7 @@ def test_misbehaving_watchtower(node_factory, bitcoind, teosd, directory): def test_get_appointment(node_factory, bitcoind, teosd, directory): - l1, l2 = node_factory.line_graph(2, opts=[{"allow_broken_log": True}, {"plugin": WT_PLUGIN}]) + l1, l2 = node_factory.line_graph(2, opts=[{}, {"plugin": WT_PLUGIN}]) # We need to register l2 with the tower tower_id = teosd.cli.gettowerinfo()["tower_id"]