mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +01:00
pytest: Add a compat()
fixture allowing checks for specific flags
Since we change the interface for `pay` and `paystatus` we need a way to determine which one to expect. This just parses the COMPAT_Vxyz flags and allows us to check if, based on the configuration, we are in compat mode for that set of changes or not.
This commit is contained in:
parent
cb00cbac7c
commit
6a75497eb2
1 changed files with 28 additions and 0 deletions
|
@ -1,8 +1,11 @@
|
|||
from utils import DEVELOPER, TEST_NETWORK # noqa: F401,F403
|
||||
from pyln.testing.fixtures import directory, test_base_dir, test_name, chainparams, node_factory, bitcoind, teardown_checks, db_provider, executor, setup_logging # noqa: F401,F403
|
||||
from pyln.testing import utils
|
||||
from utils import COMPAT
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import re
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -17,3 +20,28 @@ class LightningNode(utils.LightningNode):
|
|||
# Yes, we really want to test the local development version, not
|
||||
# something in out path.
|
||||
self.daemon.executable = 'lightningd/lightningd'
|
||||
|
||||
|
||||
class CompatLevel(object):
|
||||
"""An object that encapsulates the compat-level of our build.
|
||||
"""
|
||||
def __init__(self):
|
||||
makefile = os.path.join(os.path.dirname(__file__), "..", "Makefile")
|
||||
lines = [l for l in open(makefile, 'r') if l.startswith('COMPAT_CFLAGS')]
|
||||
assert(len(lines) == 1)
|
||||
line = lines[0]
|
||||
flags = re.findall(r'COMPAT_V([0-9]+)=1', line)
|
||||
self.compat_flags = flags
|
||||
|
||||
def __call__(self, version):
|
||||
return COMPAT and version in self.compat_flags
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def compat():
|
||||
return CompatLevel()
|
||||
|
||||
|
||||
def is_compat(version):
|
||||
compat = CompatLevel()
|
||||
return compat(version)
|
||||
|
|
Loading…
Add table
Reference in a new issue