Skip to content

Commit

Permalink
backup: Add a test to reproduce #158
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Dec 1, 2020
1 parent 0425469 commit bfff873
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions backup/test_backup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from backup import FileBackend
from flaky import flaky
from pyln.client import RpcError
from pyln.testing.fixtures import *
Expand Down Expand Up @@ -207,3 +208,24 @@ def test_warning(directory, node_factory):
assert(l1.daemon.is_in_log(
r'The `--backup-destination` option is deprecated and will be removed in future versions of the backup plugin.'
))


def test_rewrite():
tests = [
(
r'UPDATE outputs SET status=123, reserved_til=1891733WHERE prev_out_tx=1 AND prev_out_index=2',
r'UPDATE outputs SET status=123, reserved_til=1891733 WHERE prev_out_tx=1 AND prev_out_index=2',
),
]

b = FileBackend('destination', create=False)

for i, o in tests:
assert(b._rewrite_stmt(i) == o)

def test_restore_pre_4090(directory):
"""The prev-4090-backup.dbak contains faulty expansions, fix em.
"""
bdest = 'file://' + os.path.join(os.path.dirname(__file__), 'tests', 'pre-4090-backup.dbak')
rdest = os.path.join(directory, 'lightningd.sqlite.restore')
subprocess.check_call([cli_path, "restore", bdest, rdest])
Binary file added backup/tests/pre-4090-backup.dbak
Binary file not shown.

0 comments on commit bfff873

Please sign in to comment.