mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
test: add test coverage for "warnings" field in createwallet
and clarify the "warning" field behavior.
This commit is contained in:
parent
4a1e479ca6
commit
2f4a926e95
@ -15,6 +15,10 @@ from test_framework.util import (
|
||||
)
|
||||
from test_framework.wallet_util import bytes_to_wif, generate_wif_key
|
||||
|
||||
EMPTY_PASSPHRASE_MSG = "Empty string given as passphrase, wallet will not be encrypted."
|
||||
LEGACY_WALLET_MSG = "Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future."
|
||||
|
||||
|
||||
class CreateWalletTest(BitcoinTestFramework):
|
||||
def add_options(self, parser):
|
||||
self.add_wallet_options(parser)
|
||||
@ -159,7 +163,9 @@ class CreateWalletTest(BitcoinTestFramework):
|
||||
assert_equal(walletinfo['keypoolsize_hd_internal'], keys)
|
||||
# Allow empty passphrase, but there should be a warning
|
||||
resp = self.nodes[0].createwallet(wallet_name='w7', disable_private_keys=False, blank=False, passphrase='')
|
||||
assert 'Empty string given as passphrase, wallet will not be encrypted.' in resp['warning']
|
||||
assert_equal(resp["warning"], EMPTY_PASSPHRASE_MSG if self.options.descriptors else f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}")
|
||||
assert_equal(resp["warnings"], [EMPTY_PASSPHRASE_MSG] if self.options.descriptors else [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG])
|
||||
|
||||
w7 = node.get_wallet_rpc('w7')
|
||||
assert_raises_rpc_error(-15, 'Error: running with an unencrypted wallet, but walletpassphrase was called.', w7.walletpassphrase, '', 60)
|
||||
|
||||
@ -174,8 +180,19 @@ class CreateWalletTest(BitcoinTestFramework):
|
||||
|
||||
if self.is_bdb_compiled():
|
||||
self.log.info("Test legacy wallet deprecation")
|
||||
res = self.nodes[0].createwallet(wallet_name="legacy_w0", descriptors=False, passphrase=None)
|
||||
assert_equal(res["warning"], "Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future.")
|
||||
result = self.nodes[0].createwallet(wallet_name="legacy_w0", descriptors=False, passphrase=None)
|
||||
assert_equal(result, {
|
||||
"name": "legacy_w0",
|
||||
"warning": LEGACY_WALLET_MSG,
|
||||
"warnings": [LEGACY_WALLET_MSG],
|
||||
})
|
||||
result = self.nodes[0].createwallet(wallet_name="legacy_w1", descriptors=False, passphrase="")
|
||||
assert_equal(result, {
|
||||
"name": "legacy_w1",
|
||||
"warning": f"{EMPTY_PASSPHRASE_MSG}\n{LEGACY_WALLET_MSG}",
|
||||
"warnings": [EMPTY_PASSPHRASE_MSG, LEGACY_WALLET_MSG],
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
CreateWalletTest().main()
|
||||
|
Loading…
Reference in New Issue
Block a user