Skip to content

Commit

Permalink
pytest: Update tests to work for CLN v24.02
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed May 31, 2024
1 parent 2b93af1 commit 79ec640
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libs/gl-testing/gltesting/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from .scheduler import Scheduler

__all__ = [
Scheduler
]
3 changes: 2 additions & 1 deletion libs/gl-testing/gltesting/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from pathlib import Path
import logging
import sys
from pyln.testing.fixtures import bitcoind, teardown_checks, node_factory, node_cls, test_name, executor, db_provider, test_base_dir, jsonschemas
from pyln.testing.fixtures import bitcoind, teardown_checks, node_cls, test_name, executor, db_provider, test_base_dir, jsonschemas
from gltesting.network import node_factory
from pyln.testing.fixtures import directory as str_directory
from decimal import Decimal

Expand Down
56 changes: 56 additions & 0 deletions libs/gl-testing/gltesting/network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from pyln.testing.utils import NodeFactory
import pytest
from pyln.testing.fixtures import (
bitcoind, # noqa: F401
node_cls, # noqa: F401
test_name, # noqa: F401
executor, # noqa: F401
db_provider, # noqa: F401
jsonschemas, # noqa: F401
)


class GlNodeFactory(NodeFactory):
"""A temporary shim until pyln-testing learns to run multiple versions
This adds the v24.02 `--developer` option, which was not required before.
TODO Remove this shim onces pyln-testing learns about versions
PR: https://github.com/ElementsProject/lightning/pull/7173
"""

def get_node(self, options=None, *args, **kwargs):
# Until pyln-testing learns to differentiate versions we need
# to do this whenever we start a new node. pyln-testing v24.05
# promises to be multi-version compatible.
if options is None:
options = {}
options["allow-deprecated-apis"] = True
options["developer"] = None
return NodeFactory.get_node(self, options=options, *args, **kwargs)


@pytest.fixture
def node_factory(
request, # noqa: F811
directory,
test_name,
bitcoind,
executor,
db_provider,
node_cls,
jsonschemas,
):
nf = GlNodeFactory(
request,
test_name,
bitcoind,
executor,
directory=directory,
db_provider=db_provider,
node_cls=node_cls,
jsonschemas=jsonschemas,
)

yield nf
nf.killall([not n.may_fail for n in nf.nodes])
1 change: 1 addition & 0 deletions libs/gl-testing/gltesting/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(
'--dev-fast-gossip',
'--offline',
'--experimental-anchors',
'--developer', # TODO Make this multi-version capable
]

def write_node_config(self, network: str):
Expand Down

0 comments on commit 79ec640

Please sign in to comment.