Initial Vexta Core v0.1.0 release
This commit is contained in:
commit
25c454329d
2481 changed files with 689289 additions and 0 deletions
100
test/functional/wallet_listdescriptors.py
Executable file
100
test/functional/wallet_listdescriptors.py
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014-2021 The Bitcoin Core developers
|
||||
# Copyright (c) 2015-2022 The DigiByte Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test the listdescriptors RPC."""
|
||||
|
||||
from test_framework.descriptors import (
|
||||
descsum_create
|
||||
)
|
||||
from test_framework.test_framework import DigiByteTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
)
|
||||
|
||||
|
||||
class ListDescriptorsTest(DigiByteTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
self.skip_if_no_sqlite()
|
||||
|
||||
# do not create any wallet by default
|
||||
def init_wallet(self, node):
|
||||
return
|
||||
|
||||
def run_test(self):
|
||||
node = self.nodes[0]
|
||||
assert_raises_rpc_error(-18, 'No wallet is loaded.', node.listdescriptors)
|
||||
|
||||
if self.is_bdb_compiled():
|
||||
self.log.info('Test that the command is not available for legacy wallets.')
|
||||
node.createwallet(wallet_name='w1', descriptors=False)
|
||||
assert_raises_rpc_error(-4, 'listdescriptors is not available for non-descriptor wallets', node.listdescriptors)
|
||||
|
||||
self.log.info('Test the command for empty descriptors wallet.')
|
||||
node.createwallet(wallet_name='w2', blank=True, descriptors=True)
|
||||
assert_equal(0, len(node.get_wallet_rpc('w2').listdescriptors()['descriptors']))
|
||||
|
||||
self.log.info('Test the command for a default descriptors wallet.')
|
||||
node.createwallet(wallet_name='w3', descriptors=True)
|
||||
result = node.get_wallet_rpc('w3').listdescriptors()
|
||||
assert_equal("w3", result['wallet_name'])
|
||||
assert_equal(6, len(result['descriptors']))
|
||||
assert_equal(6, len([d for d in result['descriptors'] if d['active']]))
|
||||
assert_equal(3, len([d for d in result['descriptors'] if d['internal']]))
|
||||
for item in result['descriptors']:
|
||||
assert item['desc'] != ''
|
||||
assert item['next'] == 0
|
||||
assert item['range'] == [0, 0]
|
||||
assert item['timestamp'] is not None
|
||||
|
||||
self.log.info('Test descriptors with hardened derivations are listed in importable form.')
|
||||
xprv = 'tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg'
|
||||
xpub_acc = 'tpubDCMVLhErorrAGfApiJSJzEKwqeaf2z3NrkVMxgYQjZLzMjXMBeRw2muGNYbvaekAE8rUFLftyEar4LdrG2wXyyTJQZ26zptmeTEjPTaATts'
|
||||
hardened_path = '/84\'/1\'/0\''
|
||||
wallet = node.get_wallet_rpc('w2')
|
||||
wallet.importdescriptors([{
|
||||
'desc': descsum_create('wpkh(' + xprv + hardened_path + '/0/*)'),
|
||||
'timestamp': 1296688602,
|
||||
}])
|
||||
expected = {
|
||||
'wallet_name': 'w2',
|
||||
'descriptors': [
|
||||
{'desc': descsum_create('wpkh([80002067' + hardened_path + ']' + xpub_acc + '/0/*)'),
|
||||
'timestamp': 1296688602,
|
||||
'active': False,
|
||||
'range': [0, 0],
|
||||
'next': 0},
|
||||
],
|
||||
}
|
||||
assert_equal(expected, wallet.listdescriptors())
|
||||
|
||||
self.log.info("Test listdescriptors with encrypted wallet")
|
||||
wallet.encryptwallet("pass")
|
||||
assert_equal(expected, wallet.listdescriptors())
|
||||
|
||||
self.log.info('Test non-active non-range combo descriptor')
|
||||
node.createwallet(wallet_name='w4', blank=True, descriptors=True)
|
||||
wallet = node.get_wallet_rpc('w4')
|
||||
wallet.importdescriptors([{
|
||||
'desc': descsum_create('combo(' + node.get_deterministic_priv_key().key + ')'),
|
||||
'timestamp': 1296688602,
|
||||
}])
|
||||
expected = {
|
||||
'wallet_name': 'w4',
|
||||
'descriptors': [
|
||||
{'active': False,
|
||||
'desc': 'combo(0256d8280a0dd7a01a0bc2fca30a5bde5f71ac7939b7b61599614c116b3c492170)#rxcphh28',
|
||||
'timestamp': 1296688602},
|
||||
]
|
||||
}
|
||||
assert_equal(expected, wallet.listdescriptors())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ListDescriptorsTest().main()
|
||||
Loading…
Reference in a new issue