aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_descriptor.py
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-10-19 10:07:55 +0100
committerfanquake <fanquake@gmail.com>2023-10-19 10:23:44 +0100
commit091d29c49590d31dacdace24a8ae0fb781665ed6 (patch)
tree659ff858a767d0f2635f0724cc882a87cc789300 /test/functional/wallet_descriptor.py
parent5eb82d5706ea1b3b9eee2daaf6e47d1405549d4f (diff)
parent004903ebade38ba47c5ddc17b756d605b963528e (diff)
downloadbitcoin-091d29c49590d31dacdace24a8ae0fb781665ed6.tar.xz
Merge bitcoin/bitcoin#28617: test: Add Wallet Unlock Context Manager
004903ebade38ba47c5ddc17b756d605b963528e test: Add Wallet Unlock Context Manager (Brandon Odiwuor) Pull request description: Fixes #28601, see https://github.com/bitcoin/bitcoin/pull/28403#discussion_r1325426430 Add Context Manager to manage the locking and unlocking of locked wallets with a passphrase during testing. ACKs for top commit: kevkevinpal: lgtm ACK [004903e](https://github.com/bitcoin/bitcoin/pull/28617/commits/004903ebade38ba47c5ddc17b756d605b963528e) maflcko: lgtm ACK 004903ebade38ba47c5ddc17b756d605b963528e Tree-SHA512: ab234c167e71531df0d974ff9a31d444f7ce2a1d05aba5ea868cc9452f139845eeb24ca058d88f058bc02482b762adf2d99e63a6640b872cc71a57a0068abfe8
Diffstat (limited to 'test/functional/wallet_descriptor.py')
-rwxr-xr-xtest/functional/wallet_descriptor.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py
index c220675eb6..e9321b72e2 100755
--- a/test/functional/wallet_descriptor.py
+++ b/test/functional/wallet_descriptor.py
@@ -15,6 +15,7 @@ from test_framework.util import (
assert_equal,
assert_raises_rpc_error
)
+from test_framework.wallet_util import WalletUnlock
class WalletDescriptorTest(BitcoinTestFramework):
@@ -128,11 +129,10 @@ class WalletDescriptorTest(BitcoinTestFramework):
# Encrypt wallet 0
send_wrpc.encryptwallet('pass')
- send_wrpc.walletpassphrase("pass", 999000)
- addr = send_wrpc.getnewaddress()
- info2 = send_wrpc.getaddressinfo(addr)
- assert info1['hdmasterfingerprint'] != info2['hdmasterfingerprint']
- send_wrpc.walletlock()
+ with WalletUnlock(send_wrpc, "pass"):
+ addr = send_wrpc.getnewaddress()
+ info2 = send_wrpc.getaddressinfo(addr)
+ assert info1['hdmasterfingerprint'] != info2['hdmasterfingerprint']
assert 'hdmasterfingerprint' in send_wrpc.getaddressinfo(send_wrpc.getnewaddress())
info3 = send_wrpc.getaddressinfo(addr)
assert_equal(info2['desc'], info3['desc'])
@@ -142,14 +142,13 @@ class WalletDescriptorTest(BitcoinTestFramework):
send_wrpc.getnewaddress()
self.log.info("Test that unlock is needed when deriving only hardened keys in an encrypted wallet")
- send_wrpc.walletpassphrase("pass", 999000)
- send_wrpc.importdescriptors([{
- "desc": "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/0h/*h)#y4dfsj7n",
- "timestamp": "now",
- "range": [0,10],
- "active": True
- }])
- send_wrpc.walletlock()
+ with WalletUnlock(send_wrpc, "pass"):
+ send_wrpc.importdescriptors([{
+ "desc": "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/0h/*h)#y4dfsj7n",
+ "timestamp": "now",
+ "range": [0,10],
+ "active": True
+ }])
# Exhaust keypool of 100
for _ in range(100):
send_wrpc.getnewaddress(address_type='bech32')