1
1
from fixtures import * # noqa: F401,F403
2
2
from flaky import flaky # noqa: F401
3
3
from lightning import RpcError
4
+ from utils import DEVELOPER , wait_for
5
+
6
+ import os
7
+ import pytest
8
+ import re
9
+ import shutil
4
10
import signal
5
11
import time
6
12
import unittest
7
- from utils import wait_for
8
13
9
14
10
15
# Crashing or shutting-down a node raises unpredictable errors/exceptions, thus @flaky
@@ -62,12 +67,12 @@ def test_dbbackup_recover(node_factory, executor):
62
67
# l3 is our unfortunate, may_reconnect=False prevents reconnect-attempts,
63
68
# but incoming or manual connections still work
64
69
db_backup = os .path .join (node_factory .directory , "l3_lightningd.sqlite3-backup" )
65
- opts = [{'may_reconnect' : True },
66
- {'may_reconnect' : False , 'may_fail' : True },
67
- {'may_reconnect' : False , 'may_fail' : True ,
68
- 'plugin' : 'tests/dbbackup/dbbackup.py' ,
69
- 'db-backup-file' : db_backup ,
70
- 'disconnect' : ['@WIRE_UPDATE_FULFILL_HTLC' ]}]
70
+ opts = [{'may_reconnect' : True },
71
+ {'may_reconnect' : False , 'may_fail' : True },
72
+ {'may_reconnect' : False , 'may_fail' : True ,
73
+ 'plugin' : 'tests/dbbackup/dbbackup.py' ,
74
+ 'db-backup-file' : db_backup ,
75
+ 'disconnect' : ['@WIRE_UPDATE_FULFILL_HTLC' ]}]
71
76
72
77
# l3 looses its database with a beneficial HTLC in flight
73
78
l1 , l2 , l3 = node_factory .line_graph (3 , opts = opts , wait_for_announce = True )
@@ -85,10 +90,10 @@ def test_dbbackup_recover(node_factory, executor):
85
90
os .rename (db_backup , db_orig )
86
91
l3 .daemon .opts .pop ('dev-disconnect' )
87
92
l3 .daemon .opts .pop ('dev-no-reconnect' )
88
- assert l1 .rpc .listsendpays (payment_hash = phash )['payments' ][0 ]['status' ] == 'pending'
93
+ assert l1 .rpc .listsendpays (payment_hash = phash )['payments' ][0 ]['status' ] == 'pending'
89
94
l3 .start ()
90
95
l2 .rpc .connect (l3 .info ['id' ], 'localhost' , l3 .port )['id' ]
91
- wait_for (lambda : l1 .rpc .listsendpays (payment_hash = phash )['payments' ][0 ]['status' ] == 'complete' )
96
+ wait_for (lambda : l1 .rpc .listsendpays (payment_hash = phash )['payments' ][0 ]['status' ] == 'complete' )
92
97
93
98
# a HACK to get around `ValueError: 2 nodes had unexpected reconnections`
94
99
l3 .daemon .logs = [re .sub ('Peer has reconnected' , 'MODDED_PeerHasReconnected' , l ) for l in l3 .daemon .logs ]
@@ -150,26 +155,7 @@ def test_dbbackup_plugin_kill(node_factory, executor):
150
155
# kill the plugin, be a bit careful extracting pid from log
151
156
logline = l1 .daemon .is_in_log ('plugin-manager started\(\d+\).*dbbackup.py' )
152
157
assert logline is not None
153
- pid = int (re .search (r'plugin-manager started\((\d+)\).*dbbackup.py' ,logline ).group (1 ))
158
+ pid = int (re .search (r'plugin-manager started\((\d+)\).*dbbackup.py' , logline ).group (1 ))
154
159
os .kill (pid , signal .SIGTERM )
155
160
time .sleep (1 )
156
161
assert l1 .daemon .is_in_log (r'\*\*BROKEN\*\*' )
157
-
158
-
159
- # @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
160
- # def test_dummy(node_factory, executor):
161
- # # l1, l2 = node_factory.line_graph(2, wait_for_announce=True,
162
- # # opts=[{'may_reconnect': False},
163
- # # {'may_reconnect': False,
164
- # # 'disconnect': ['@WIRE_COMMITMENT_SIGNED']}])
165
- # l1 = node_factory.get_node(allow_broken_log=True, random_hsm=True, start=False,
166
- # options={'plugin': 'tests/dbbackup/dbbackup.py',
167
- # 'db-backup-file': None})
168
- #
169
- # # Now with an invalid path, should error and shutdown
170
- # bad_path = node_factory.directory
171
- # l1.daemon.opts['db-backup-file'] = bad_path
172
- # with pytest.raises(ConnectionResetError):
173
- # l1.start()
174
- # import ipdb; ipdb.set_trace()
175
- # print("\n".join(l1.daemon.logs))
0 commit comments