diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2022-11-08 01:24:27 +0100 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2022-11-08 12:29:16 +0100 |
commit | 3198e4239e848bbb119e3638677aa9bcf8353ca6 (patch) | |
tree | b9973c437812c5a99fe6a9c2887597fd748a3acf /test | |
parent | 349ed2a0eed3aaaf199ead93057c97730869c3a3 (diff) | |
download | bitcoin-3198e4239e848bbb119e3638677aa9bcf8353ca6.tar.xz |
test: check that loading descriptor wallet with legacy entries throws error
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/wallet_descriptor.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py index 5dc23ba245..295a8416ba 100755 --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -3,6 +3,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test descriptor wallet function.""" +import os +import sqlite3 from test_framework.blocktools import COINBASE_MATURITY from test_framework.test_framework import BitcoinTestFramework @@ -209,5 +211,15 @@ class WalletDescriptorTest(BitcoinTestFramework): imp_addr = imp_rpc.getnewaddress(address_type=addr_type) assert_equal(exp_addr, imp_addr) + self.log.info("Test that loading descriptor wallet containing legacy key types throws error") + self.nodes[0].createwallet(wallet_name="crashme", descriptors=True) + self.nodes[0].unloadwallet("crashme") + wallet_db = os.path.join(self.nodes[0].datadir, self.chain, "wallets", "crashme", self.wallet_data_filename) + with sqlite3.connect(wallet_db) as conn: + # add "cscript" entry: key type is uint160 (20 bytes), value type is CScript (zero-length here) + conn.execute('INSERT INTO main VALUES(?, ?)', (b'\x07cscript' + b'\x00'*20, b'\x00')) + assert_raises_rpc_error(-4, "Unexpected legacy entry in descriptor wallet found.", self.nodes[0].loadwallet, "crashme") + + if __name__ == '__main__': WalletDescriptorTest().main () |