This commit is contained in:
Martin Zumsande 2025-04-29 11:51:51 +02:00 committed by GitHub
commit e0ed0638a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 80 additions and 54 deletions

View file

@ -38,6 +38,7 @@ from test_framework.util import (
assert_equal, assert_equal,
assert_not_equal, assert_not_equal,
assert_raises_rpc_error, assert_raises_rpc_error,
convert_to_json_for_cli,
ensure_for, ensure_for,
sha256sum_file, sha256sum_file,
try_rpc, try_rpc,
@ -481,7 +482,7 @@ class AssumeutxoTest(BitcoinTestFramework):
# Use a hash instead of a height # Use a hash instead of a height
prev_snap_hash = n0.getblockhash(prev_snap_height) prev_snap_hash = n0.getblockhash(prev_snap_height)
dump_output5 = n0.dumptxoutset('utxos5.dat', rollback=prev_snap_hash) dump_output5 = n0.dumptxoutset('utxos5.dat', rollback=convert_to_json_for_cli(self.options.usecli, prev_snap_hash))
assert_equal(sha256sum_file(dump_output4['path']), sha256sum_file(dump_output5['path'])) assert_equal(sha256sum_file(dump_output4['path']), sha256sum_file(dump_output5['path']))
# TODO: This is a hack to set m_best_header to the correct value after # TODO: This is a hack to set m_best_header to the correct value after

View file

@ -30,6 +30,7 @@ from test_framework.util import (
assert_not_equal, assert_not_equal,
assert_equal, assert_equal,
assert_raises_rpc_error, assert_raises_rpc_error,
convert_to_json_for_cli,
) )
from test_framework.wallet import ( from test_framework.wallet import (
MiniWallet, MiniWallet,
@ -41,7 +42,6 @@ class CoinStatsIndexTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 2 self.num_nodes = 2
self.supports_cli = False
self.extra_args = [ self.extra_args = [
[], [],
["-coinstatsindex"] ["-coinstatsindex"]
@ -104,7 +104,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
assert_equal(res0, res2) assert_equal(res0, res2)
# Fetch old stats by hash # Fetch old stats by hash
res3 = index_node.gettxoutsetinfo(hash_option, res0['bestblock']) res3 = index_node.gettxoutsetinfo(hash_option, convert_to_json_for_cli(self.options.usecli, res0['bestblock']))
del res3['block_info'], res3['total_unspendable_amount'] del res3['block_info'], res3['total_unspendable_amount']
res3.pop('muhash', None) res3.pop('muhash', None)
assert_equal(res0, res3) assert_equal(res0, res3)
@ -244,7 +244,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
assert_equal(res12, res10) assert_equal(res12, res10)
self.log.info("Test obtaining info for a non-existent block hash") self.log.info("Test obtaining info for a non-existent block hash")
assert_raises_rpc_error(-5, "Block not found", index_node.gettxoutsetinfo, hash_type="none", hash_or_height="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", use_index=True) assert_raises_rpc_error(-5, "Block not found", index_node.gettxoutsetinfo, hash_type="none", hash_or_height=convert_to_json_for_cli(self.options.usecli, "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), use_index=True)
def _test_use_index_option(self): def _test_use_index_option(self):
self.log.info("Test use_index option for nodes running the index") self.log.info("Test use_index option for nodes running the index")
@ -279,7 +279,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
assert_not_equal(res["muhash"], res_invalid["muhash"]) assert_not_equal(res["muhash"], res_invalid["muhash"])
# Test that requesting reorged out block by hash is still returning correct results # Test that requesting reorged out block by hash is still returning correct results
res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=reorg_block) res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=convert_to_json_for_cli(self.options.usecli, reorg_block))
assert_equal(res_invalid2["muhash"], res_invalid["muhash"]) assert_equal(res_invalid2["muhash"], res_invalid["muhash"])
assert_not_equal(res["muhash"], res_invalid2["muhash"]) assert_not_equal(res["muhash"], res_invalid2["muhash"])

View file

@ -14,6 +14,7 @@ class FeatureFastpruneTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.extra_args = [["-fastprune"]] self.extra_args = [["-fastprune"]]
self.supports_cli = False
def run_test(self): def run_test(self):
self.log.info("ensure that large blocks don't crash or freeze in -fastprune") self.log.info("ensure that large blocks don't crash or freeze in -fastprune")

View file

@ -148,6 +148,7 @@ class EstimateFeeTest(BitcoinTestFramework):
["-blockmaxweight=68000"], ["-blockmaxweight=68000"],
["-blockmaxweight=32000"], ["-blockmaxweight=32000"],
] ]
self.supports_cli = False
def setup_network(self): def setup_network(self):
""" """

View file

@ -17,6 +17,7 @@ class BlockstoreReindexTest(BitcoinTestFramework):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 1 self.num_nodes = 1
self.extra_args = [["-fastprune"]] self.extra_args = [["-fastprune"]]
self.supports_cli = False
def reindex_readonly(self): def reindex_readonly(self):
self.log.debug("Generate block big enough to start second block file") self.log.debug("Generate block big enough to start second block file")

View file

@ -1320,6 +1320,7 @@ class TaprootTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.setup_clean_chain = True self.setup_clean_chain = True
self.supports_cli = False
def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_weight=0, witness=False, accept=False): def block_submit(self, node, txs, msg, err_msg, cb_pubkey=None, fees=0, sigops_weight=0, witness=False, accept=False):

View file

@ -36,6 +36,7 @@ class PackageRBFTest(BitcoinTestFramework):
"-datacarriersize=100000", "-datacarriersize=100000",
"-maxmempool=5", "-maxmempool=5",
]] * self.num_nodes ]] * self.num_nodes
self.supports_cli = False
def assert_mempool_contents(self, expected=None): def assert_mempool_contents(self, expected=None):
mempool_util.assert_mempool_contents(self, self.nodes[0], expected, sync=False) mempool_util.assert_mempool_contents(self, self.nodes[0], expected, sync=False)

View file

@ -12,6 +12,7 @@ class NetDeadlockTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 2 self.num_nodes = 2
self.supports_cli = False
def run_test(self): def run_test(self):
node0 = self.nodes[0] node0 = self.nodes[0]

View file

@ -69,6 +69,7 @@ class TxDownloadTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 2 self.num_nodes = 2
self.extra_args= [['-datacarriersize=100000', '-maxmempool=5', '-persistmempool=0']] * self.num_nodes self.extra_args= [['-datacarriersize=100000', '-maxmempool=5', '-persistmempool=0']] * self.num_nodes
self.supports_cli = False
def test_tx_requests(self): def test_tx_requests(self):
self.log.info("Test that we request transactions from all our peers, eventually") self.log.info("Test that we request transactions from all our peers, eventually")

View file

@ -28,7 +28,6 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 3 self.num_nodes = 3
self.supports_cli = False
def create_keys(self, num_keys): def create_keys(self, num_keys):
self.pub = [] self.pub = []

View file

@ -32,7 +32,7 @@ class DeprecatedRpcTest(BitcoinTestFramework):
self.log.info("Tests for deprecated wallet-related RPC methods (if any)") self.log.info("Tests for deprecated wallet-related RPC methods (if any)")
self.log.info("Test settxfee RPC deprecation") self.log.info("Test settxfee RPC deprecation")
self.nodes[0].createwallet("settxfeerpc") self.nodes[0].createwallet("settxfeerpc")
assert_raises_rpc_error(-32, 'settxfee is deprecated and will be fully removed in v31.0.', self.nodes[0].rpc.settxfee, 0.01) assert_raises_rpc_error(-32, 'settxfee is deprecated and will be fully removed in v31.0.', self.nodes[0].settxfee, 0.01)
if __name__ == '__main__': if __name__ == '__main__':
DeprecatedRpcTest(__file__).main() DeprecatedRpcTest(__file__).main()

View file

@ -21,17 +21,17 @@ class EstimateFeeTest(BitcoinTestFramework):
assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee) assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee)
assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee) assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee)
# wrong type for conf_target # cli handles wrong types differently
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimatesmartfee, 'foo') if not self.options.usecli:
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimaterawfee, 'foo') # wrong type for conf_target
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimatesmartfee, 'foo')
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimaterawfee, 'foo')
# wrong type for estimatesmartfee(estimate_mode)
assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", self.nodes[0].estimatesmartfee, 1, 1)
# wrong type for estimaterawfee(threshold)
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimaterawfee, 1, 'foo')
# wrong type for estimatesmartfee(estimate_mode)
assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", self.nodes[0].estimatesmartfee, 1, 1)
assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"', self.nodes[0].estimatesmartfee, 1, 'foo') assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"', self.nodes[0].estimatesmartfee, 1, 'foo')
# wrong type for estimaterawfee(threshold)
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].estimaterawfee, 1, 'foo')
# extra params # extra params
assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', 1) assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', 1)
assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee, 1, 1, 1) assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee, 1, 1, 1)

View file

@ -124,11 +124,12 @@ class RPCGenerateTest(BitcoinTestFramework):
"cli option. Refer to -help for more information.\n" "cli option. Refer to -help for more information.\n"
) )
self.log.info("Test rpc generate raises with message to use cli option") if not self.options.usecli:
assert_raises_rpc_error(-32601, message, self.nodes[0].rpc.generate) self.log.info("Test rpc generate raises with message to use cli option")
assert_raises_rpc_error(-32601, message, self.nodes[0].rpc.generate)
self.log.info("Test rpc generate help prints message to use cli option") self.log.info("Test rpc generate help prints message to use cli option")
assert_equal(message, self.nodes[0].help("generate")) assert_equal(message, self.nodes[0].help("generate"))
self.log.info("Test rpc generate is a hidden command not discoverable in general help") self.log.info("Test rpc generate is a hidden command not discoverable in general help")
assert message not in self.nodes[0].help() assert message not in self.nodes[0].help()

View file

@ -67,8 +67,11 @@ class GetBlockFromPeerTest(BitcoinTestFramework):
self.log.info("Arguments must be valid") self.log.info("Arguments must be valid")
assert_raises_rpc_error(-8, "hash must be of length 64 (not 4, for '1234')", self.nodes[0].getblockfrompeer, "1234", peer_0_peer_1_id) assert_raises_rpc_error(-8, "hash must be of length 64 (not 4, for '1234')", self.nodes[0].getblockfrompeer, "1234", peer_0_peer_1_id)
assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", self.nodes[0].getblockfrompeer, 1234, peer_0_peer_1_id)
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].getblockfrompeer, short_tip, "0") # cli handles wrong types differently
if not self.options.usecli:
assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", self.nodes[0].getblockfrompeer, 1234, peer_0_peer_1_id)
assert_raises_rpc_error(-3, "JSON value of type string is not of expected type number", self.nodes[0].getblockfrompeer, short_tip, "0")
self.log.info("We must already have the header") self.log.info("We must already have the header")
assert_raises_rpc_error(-1, "Block header missing", self.nodes[0].getblockfrompeer, "00" * 32, 0) assert_raises_rpc_error(-1, "Block header missing", self.nodes[0].getblockfrompeer, "00" * 32, 0)

View file

@ -12,6 +12,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,
assert_raises_rpc_error, assert_raises_rpc_error,
convert_to_json_for_cli,
) )
import json import json
import os import os
@ -35,7 +36,6 @@ class GetblockstatsTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.setup_clean_chain = True self.setup_clean_chain = True
self.supports_cli = False
def get_stats(self): def get_stats(self):
return [self.nodes[0].getblockstats(hash_or_height=self.start_height + i) for i in range(self.max_stat_pos+1)] return [self.nodes[0].getblockstats(hash_or_height=self.start_height + i) for i in range(self.max_stat_pos+1)]
@ -119,7 +119,7 @@ class GetblockstatsTest(BitcoinTestFramework):
# Check selecting block by hash too # Check selecting block by hash too
blockhash = self.expected_stats[i]['blockhash'] blockhash = self.expected_stats[i]['blockhash']
stats_by_hash = self.nodes[0].getblockstats(hash_or_height=blockhash) stats_by_hash = self.nodes[0].getblockstats(hash_or_height=convert_to_json_for_cli(self.options.usecli, blockhash))
assert_equal(stats_by_hash, self.expected_stats[i]) assert_equal(stats_by_hash, self.expected_stats[i])
# Make sure each stat can be queried on its own # Make sure each stat can be queried on its own
@ -161,10 +161,10 @@ class GetblockstatsTest(BitcoinTestFramework):
self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee', f'aaa{inv_sel_stat}']) self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee', f'aaa{inv_sel_stat}'])
# Mainchain's genesis block shouldn't be found on regtest # Mainchain's genesis block shouldn't be found on regtest
assert_raises_rpc_error(-5, 'Block not found', self.nodes[0].getblockstats, assert_raises_rpc_error(-5, 'Block not found', self.nodes[0].getblockstats,
hash_or_height='000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f') hash_or_height=convert_to_json_for_cli(self.options.usecli,'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'))
# Invalid number of args # Invalid number of args
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats, '00', 1, 2) assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats, convert_to_json_for_cli(self.options.usecli,'00'), 1, 2)
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats) assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats)
self.log.info('Test block height 0') self.log.info('Test block height 0')
@ -185,7 +185,7 @@ class GetblockstatsTest(BitcoinTestFramework):
self.log.info("Test when only header is known") self.log.info("Test when only header is known")
block = self.generateblock(self.nodes[0], output="raw(55)", transactions=[], submit=False) block = self.generateblock(self.nodes[0], output="raw(55)", transactions=[], submit=False)
self.nodes[0].submitheader(block["hex"]) self.nodes[0].submitheader(block["hex"])
assert_raises_rpc_error(-1, "Block not available (not fully downloaded)", lambda: self.nodes[0].getblockstats(block['hash'])) assert_raises_rpc_error(-1, "Block not available (not fully downloaded)", lambda: self.nodes[0].getblockstats(convert_to_json_for_cli(self.options.usecli,block['hash'])))
self.log.info('Test when block is missing') self.log.info('Test when block is missing')
(self.nodes[0].blocks_path / 'blk00000.dat').rename(self.nodes[0].blocks_path / 'blk00000.dat.backup') (self.nodes[0].blocks_path / 'blk00000.dat').rename(self.nodes[0].blocks_path / 'blk00000.dat.backup')

View file

@ -35,7 +35,9 @@ class DescriptorTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
assert_raises_rpc_error(-1, 'getdescriptorinfo', self.nodes[0].getdescriptorinfo) assert_raises_rpc_error(-1, 'getdescriptorinfo', self.nodes[0].getdescriptorinfo)
assert_raises_rpc_error(-3, 'JSON value of type number is not of expected type string', self.nodes[0].getdescriptorinfo, 1) # cli handles wrong types differently
if not self.options.usecli:
assert_raises_rpc_error(-3, 'JSON value of type number is not of expected type string', self.nodes[0].getdescriptorinfo, 1)
assert_raises_rpc_error(-5, "'' is not a valid descriptor function", self.nodes[0].getdescriptorinfo, "") assert_raises_rpc_error(-5, "'' is not a valid descriptor function", self.nodes[0].getdescriptorinfo, "")
assert_raises_rpc_error(-5, "pk(): Key ' 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' is invalid due to whitespace", self.nodes[0].getdescriptorinfo, "pk( 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)") assert_raises_rpc_error(-5, "pk(): Key ' 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' is invalid due to whitespace", self.nodes[0].getdescriptorinfo, "pk( 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)")
assert_raises_rpc_error(-5, "pk(): Key '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 ' is invalid due to whitespace", self.nodes[0].getdescriptorinfo, "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 )") assert_raises_rpc_error(-5, "pk(): Key '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 ' is invalid due to whitespace", self.nodes[0].getdescriptorinfo, "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 )")

View file

@ -45,7 +45,6 @@ def process_mapping(fname):
class HelpRpcTest(BitcoinTestFramework): class HelpRpcTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.supports_cli = False
self.uses_wallet = None self.uses_wallet = None
def run_test(self): def run_test(self):
@ -93,7 +92,8 @@ class HelpRpcTest(BitcoinTestFramework):
assert_raises_rpc_error(-1, 'help', node.help, 'foo', 'bar') assert_raises_rpc_error(-1, 'help', node.help, 'foo', 'bar')
# invalid argument # invalid argument
assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", node.help, 0) if not self.options.usecli:
assert_raises_rpc_error(-3, "JSON value of type number is not of expected type string", node.help, 0)
# help of unknown command # help of unknown command
assert_equal(node.help('foo'), 'help: unknown command: foo') assert_equal(node.help('foo'), 'help: unknown command: foo')

View file

@ -97,10 +97,12 @@ class InvalidAddressErrorMessageTest(BitcoinTestFramework):
node = self.nodes[0] node = self.nodes[0]
# Missing arg returns the help text
assert_raises_rpc_error(-1, "Return information about the given bitcoin address.", node.validateaddress) if not self.options.usecli:
# Explicit None is not allowed for required parameters # Missing arg returns the help text
assert_raises_rpc_error(-3, "JSON value of type null is not of expected type string", node.validateaddress, None) assert_raises_rpc_error(-1, "Return information about the given bitcoin address.", node.validateaddress)
# Explicit None is not allowed for required parameters
assert_raises_rpc_error(-3, "JSON value of type null is not of expected type string", node.validateaddress, None)
def test_getaddressinfo(self): def test_getaddressinfo(self):
node = self.nodes[0] node = self.nodes[0]

View file

@ -38,6 +38,7 @@ class RPCPackagesTest(BitcoinTestFramework):
self.setup_clean_chain = True self.setup_clean_chain = True
# whitelist peers to speed up tx relay / mempool sync # whitelist peers to speed up tx relay / mempool sync
self.noban_tx_relay = True self.noban_tx_relay = True
self.supports_cli = False
def assert_testres_equal(self, package_hex, testres_expected): def assert_testres_equal(self, package_hex, testres_expected):
"""Shuffle package_hex and assert that the testmempoolaccept result matches testres_expected. This should only """Shuffle package_hex and assert that the testmempoolaccept result matches testres_expected. This should only

View file

@ -66,7 +66,6 @@ class PSBTTest(BitcoinTestFramework):
# whitelist peers to speed up tx relay / mempool sync # whitelist peers to speed up tx relay / mempool sync
for args in self.extra_args: for args in self.extra_args:
args.append("-whitelist=noban@127.0.0.1") args.append("-whitelist=noban@127.0.0.1")
self.supports_cli = False
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()
@ -90,7 +89,7 @@ class PSBTTest(BitcoinTestFramework):
signed_psbt_obj.g.map[PSBT_GLOBAL_UNSIGNED_TX] = bytes.fromhex(raw) signed_psbt_obj.g.map[PSBT_GLOBAL_UNSIGNED_TX] = bytes.fromhex(raw)
# Check that the walletprocesspsbt call succeeds but also recognizes that the transaction is not complete # Check that the walletprocesspsbt call succeeds but also recognizes that the transaction is not complete
signed_psbt_incomplete = wallet.walletprocesspsbt(signed_psbt_obj.to_base64(), finalize=False) signed_psbt_incomplete = wallet.walletprocesspsbt(psbt=signed_psbt_obj.to_base64(), finalize=False)
assert signed_psbt_incomplete["complete"] is False assert signed_psbt_incomplete["complete"] is False
def test_utxo_conversion(self): def test_utxo_conversion(self):

View file

@ -33,6 +33,7 @@ class RPCWhitelistTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.supports_cli = False
def run_test(self): def run_test(self):
# 0 => Username # 0 => Username

View file

@ -862,7 +862,7 @@ def arg_to_cli(arg):
return str(arg).lower() return str(arg).lower()
elif arg is None: elif arg is None:
return 'null' return 'null'
elif isinstance(arg, dict) or isinstance(arg, list): elif isinstance(arg, dict) or isinstance(arg, list) or isinstance(arg, tuple):
return json.dumps(arg, default=serialization_fallback) return json.dumps(arg, default=serialization_fallback)
else: else:
return str(arg) return str(arg)
@ -899,7 +899,7 @@ class TestNodeCLI():
def send_cli(self, clicommand=None, *args, **kwargs): def send_cli(self, clicommand=None, *args, **kwargs):
"""Run bitcoin-cli command. Deserializes returned string as python object.""" """Run bitcoin-cli command. Deserializes returned string as python object."""
pos_args = [arg_to_cli(arg) for arg in args] pos_args = [arg_to_cli(arg) for arg in args]
named_args = [str(key) + "=" + arg_to_cli(value) for (key, value) in kwargs.items()] named_args = [str(key) + "=" + arg_to_cli(value) for (key, value) in kwargs.items() if value is not None]
p_args = self.binaries.rpc_argv() + [f"-datadir={self.datadir}"] + self.options p_args = self.binaries.rpc_argv() + [f"-datadir={self.datadir}"] + self.options
if named_args: if named_args:
p_args += ["-named"] p_args += ["-named"]
@ -948,8 +948,8 @@ class RPCOverloadWrapper():
def addmultisigaddress(self, nrequired, keys, *, label=None, address_type=None): def addmultisigaddress(self, nrequired, keys, *, label=None, address_type=None):
wallet_info = self.getwalletinfo() wallet_info = self.getwalletinfo()
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']): if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type) return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type=address_type)
cms = self.createmultisig(nrequired, keys, address_type) cms = self.createmultisig(nrequired, keys, address_type=address_type)
req = [{ req = [{
'desc': cms['descriptor'], 'desc': cms['descriptor'],
'timestamp': 0, 'timestamp': 0,

View file

@ -610,3 +610,8 @@ def sync_txindex(test_framework, node):
sync_start = int(time.time()) sync_start = int(time.time())
test_framework.wait_until(lambda: node.getindexinfo("txindex")["txindex"]["synced"]) test_framework.wait_until(lambda: node.getindexinfo("txindex")["txindex"]["synced"])
test_framework.log.debug(f"Synced in {time.time() - sync_start} seconds") test_framework.log.debug(f"Synced in {time.time() - sync_start} seconds")
def convert_to_json_for_cli(cli, text):
if cli:
return json.dumps(text)
return text

View file

@ -78,7 +78,6 @@ class AddressTypeTest(BitcoinTestFramework):
] ]
# whitelist peers to speed up tx relay / mempool sync # whitelist peers to speed up tx relay / mempool sync
self.noban_tx_relay = True self.noban_tx_relay = True
self.supports_cli = False
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()

View file

@ -139,8 +139,9 @@ class BumpFeeTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, msg, rbf_node.bumpfee, rbfid, fee_rate=zero_value) assert_raises_rpc_error(-8, msg, rbf_node.bumpfee, rbfid, fee_rate=zero_value)
msg = "Invalid amount" msg = "Invalid amount"
# Test fee_rate values that don't pass fixed-point parsing checks. # Test fee_rate values that don't pass fixed-point parsing checks.
for invalid_value in ["", 0.000000001, 1e-09, 1.111111111, 1111111111111111, "31.999999999999999999999"]: if not self.options.usecli:
assert_raises_rpc_error(-3, msg, rbf_node.bumpfee, rbfid, fee_rate=invalid_value) for invalid_value in ["", 0.000000001, 1e-09, 1.111111111, 1111111111111111, "31.999999999999999999999"]:
assert_raises_rpc_error(-3, msg, rbf_node.bumpfee, rbfid, fee_rate=invalid_value)
# Test fee_rate values that cannot be represented in sat/vB. # Test fee_rate values that cannot be represented in sat/vB.
for invalid_value in [0.0001, 0.00000001, 0.00099999, 31.99999999]: for invalid_value in [0.0001, 0.00000001, 0.00099999, 31.99999999]:
assert_raises_rpc_error(-3, msg, rbf_node.bumpfee, rbfid, fee_rate=invalid_value) assert_raises_rpc_error(-3, msg, rbf_node.bumpfee, rbfid, fee_rate=invalid_value)
@ -164,9 +165,10 @@ class BumpFeeTest(BitcoinTestFramework):
rbf_node.bumpfee, rbfid, {"confTarget": 123, "conf_target": 456}) rbf_node.bumpfee, rbfid, {"confTarget": 123, "conf_target": 456})
self.log.info("Test invalid estimate_mode settings") self.log.info("Test invalid estimate_mode settings")
for k, v in {"number": 42, "object": {"foo": "bar"}}.items(): if not self.options.usecli:
assert_raises_rpc_error(-3, f"JSON value of type {k} for field estimate_mode is not of expected type string", for k, v in {"number": 42, "object": {"foo": "bar"}}.items():
rbf_node.bumpfee, rbfid, estimate_mode=v) assert_raises_rpc_error(-3, f"JSON value of type {k} for field estimate_mode is not of expected type string",
rbf_node.bumpfee, rbfid, estimate_mode=v)
for mode in ["foo", Decimal("3.1415"), "sat/B", "BTC/kB"]: for mode in ["foo", Decimal("3.1415"), "sat/B", "BTC/kB"]:
assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"', assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"',
rbf_node.bumpfee, rbfid, estimate_mode=mode) rbf_node.bumpfee, rbfid, estimate_mode=mode)

View file

@ -90,14 +90,15 @@ class WalletEncryptionTest(BitcoinTestFramework):
assert_equal(actual_time, expected_time) assert_equal(actual_time, expected_time)
self.nodes[0].walletlock() self.nodes[0].walletlock()
# Test passphrase with null characters if not self.options.usecli: # can't be done with the test framework for cli since subprocess.Popen doesn't allow null characters
passphrase_with_nulls = "Phrase\0With\0Nulls" # Test passphrase with null characters
self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls) passphrase_with_nulls = "Phrase\0With\0Nulls"
# walletpassphrasechange should not stop at null characters self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls)
assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10) # walletpassphrasechange should not stop at null characters
with WalletUnlock(self.nodes[0], passphrase_with_nulls): assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10)
sig = self.nodes[0].signmessage(address, msg) with WalletUnlock(self.nodes[0], passphrase_with_nulls):
assert self.nodes[0].verifymessage(address, sig, msg) sig = self.nodes[0].signmessage(address, msg)
assert self.nodes[0].verifymessage(address, sig, msg)
self.log.info("Test that wallets without private keys cannot be encrypted") self.log.info("Test that wallets without private keys cannot be encrypted")
self.nodes[0].createwallet(wallet_name="noprivs", disable_private_keys=True) self.nodes[0].createwallet(wallet_name="noprivs", disable_private_keys=True)

View file

@ -49,6 +49,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# whitelist peers to speed up tx relay / mempool sync # whitelist peers to speed up tx relay / mempool sync
self.noban_tx_relay = True self.noban_tx_relay = True
self.rpc_timeout = 90 # to prevent timeouts in `test_transaction_too_large` self.rpc_timeout = 90 # to prevent timeouts in `test_transaction_too_large`
self.supports_cli = False
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()

View file

@ -206,6 +206,7 @@ class WalletMiniscriptTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
self.rpc_timeout = 180 self.rpc_timeout = 180
self.supports_cli = False
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()

View file

@ -29,6 +29,7 @@ class WalletSendTest(BitcoinTestFramework):
self.num_nodes = 2 self.num_nodes = 2
# whitelist peers to speed up tx relay / mempool sync # whitelist peers to speed up tx relay / mempool sync
self.noban_tx_relay = True self.noban_tx_relay = True
self.supports_cli = False
self.extra_args = [ self.extra_args = [
["-walletrbf=1"], ["-walletrbf=1"],
["-walletrbf=1"] ["-walletrbf=1"]