Skip to content

Commit 703b758

Browse files
committed
qa: Close SQLite connection properly
Connection object used as context manager only commits or rollbacks transactions, so the connection object should be closed manually. Fixes the following error on Windows: ``` PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ... ```
1 parent 2fa60f0 commit 703b758

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/functional/wallet_descriptor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ def run_test(self):
235235
self.nodes[0].createwallet(wallet_name="crashme", descriptors=True)
236236
self.nodes[0].unloadwallet("crashme")
237237
wallet_db = os.path.join(self.nodes[0].wallets_path, "crashme", self.wallet_data_filename)
238-
with sqlite3.connect(wallet_db) as conn:
238+
conn = sqlite3.connect(wallet_db)
239+
with conn:
239240
# add "cscript" entry: key type is uint160 (20 bytes), value type is CScript (zero-length here)
240241
conn.execute('INSERT INTO main VALUES(?, ?)', (b'\x07cscript' + b'\x00'*20, b'\x00'))
242+
conn.close()
241243
assert_raises_rpc_error(-4, "Unexpected legacy entry in descriptor wallet found.", self.nodes[0].loadwallet, "crashme")
242244

243245

0 commit comments

Comments
 (0)