tests: use data_directory
This commit is contained in:
parent
6ccaa0573b
commit
61bc0ffbc8
@ -308,6 +308,33 @@ def lianad_multisig(bitcoin_backend, directory):
|
||||
|
||||
lianad.cleanup()
|
||||
|
||||
@pytest.fixture
|
||||
def lianad_multisig_legacy_datadir(bitcoin_backend, directory):
|
||||
datadir = os.path.join(directory, "lianad")
|
||||
os.makedirs(datadir, exist_ok=True)
|
||||
|
||||
# A 3-of-4 that degrades into a 2-of-5 after 10 blocks
|
||||
csv_value = 10
|
||||
signer = MultiSigner(4, {csv_value: 5}, is_taproot=USE_TAPROOT)
|
||||
main_desc = Descriptor.from_str(multisig_desc(signer, csv_value, USE_TAPROOT, 3, 2))
|
||||
|
||||
lianad = Lianad(
|
||||
datadir,
|
||||
signer,
|
||||
main_desc,
|
||||
bitcoin_backend,
|
||||
legacy_datadir=True
|
||||
)
|
||||
|
||||
try:
|
||||
lianad.start()
|
||||
yield lianad
|
||||
except Exception:
|
||||
lianad.cleanup()
|
||||
raise
|
||||
|
||||
lianad.cleanup()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def lianad_multisig_2_of_2(bitcoin_backend, directory):
|
||||
|
||||
@ -31,6 +31,7 @@ class Lianad(TailableProc):
|
||||
signer,
|
||||
multi_desc,
|
||||
bitcoin_backend,
|
||||
legacy_datadir=False
|
||||
):
|
||||
TailableProc.__init__(self, datadir, verbose=VERBOSE)
|
||||
|
||||
@ -44,12 +45,17 @@ class Lianad(TailableProc):
|
||||
|
||||
self.conf_file = os.path.join(datadir, "config.toml")
|
||||
self.cmd_line = [LIANAD_PATH, "--conf", f"{self.conf_file}"]
|
||||
socket_path = os.path.join(os.path.join(datadir, "regtest"), "lianad_rpc")
|
||||
data_directory = os.path.join(datadir, "regtest")
|
||||
socket_path = os.path.join(data_directory, "lianad_rpc")
|
||||
self.rpc = UnixDomainSocketRpc(socket_path)
|
||||
self.bitcoin_backend = bitcoin_backend
|
||||
|
||||
with open(self.conf_file, "w") as f:
|
||||
f.write(f"data_dir = '{datadir}'\n")
|
||||
if legacy_datadir:
|
||||
f.write(f"data_dir = '{datadir}'\n")
|
||||
else:
|
||||
f.write(f"data_directory = '{data_directory}'\n")
|
||||
|
||||
f.write(f"log_level = '{LOG_LEVEL}'\n")
|
||||
|
||||
f.write(f'main_descriptor = "{multi_desc}"\n')
|
||||
|
||||
@ -278,9 +278,9 @@ def test_coinbase_deposit(lianad, bitcoind):
|
||||
BITCOIN_BACKEND_TYPE is not BitcoinBackendType.Bitcoind,
|
||||
reason="Only bitcoind backend was available for older lianad versions.",
|
||||
)
|
||||
def test_migration(lianad_multisig, bitcoind):
|
||||
def test_migration(lianad_multisig_legacy_datadir, bitcoind):
|
||||
"""Test we can start a newer lianad on a datadir created by an older lianad."""
|
||||
lianad = lianad_multisig
|
||||
lianad = lianad_multisig_legacy_datadir
|
||||
|
||||
# Set the old binary and re-create the datadir.
|
||||
lianad.cmd_line[0] = OLD_LIANAD_PATH
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user