diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -13,9 +13,6 @@ self.setup_clean_chain = True self.num_nodes = 1 - def skip_test_if_missing_module(self): - self.skip_if_no_wallet() - def test_config_file_parser(self): # Assume node is stopped @@ -176,8 +173,18 @@ self.nodes[0].datadir = new_data_dir_2 self.start_node(0, ['-datadir=' + new_data_dir_2, '-conf=' + conf_file, '-wallet=w2']) - assert os.path.exists(os.path.join( - new_data_dir_2, 'regtest', 'wallets', 'w2')) + assert os.path.exists( + os.path.join( + new_data_dir_2, + 'regtest', + 'blocks')) + if self.is_wallet_compiled(): + assert os.path.exists( + os.path.join( + new_data_dir_2, + 'regtest', + 'wallets', + 'w2')) if __name__ == '__main__': diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -6,6 +6,7 @@ """Test the -alertnotify, -blocknotify and -walletnotify options.""" import os +from test_framework.address import ADDRESS_BCHREG_UNSPENDABLE from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, connect_nodes_bi, wait_until @@ -17,9 +18,6 @@ self.num_nodes = 2 self.setup_clean_chain = True - def skip_test_if_missing_module(self): - self.skip_if_no_wallet() - def setup_network(self): self.alertnotify_dir = os.path.join(self.options.tmpdir, "alertnotify") self.blocknotify_dir = os.path.join(self.options.tmpdir, "blocknotify") @@ -30,19 +28,22 @@ os.mkdir(self.walletnotify_dir) # -alertnotify and -blocknotify on node0, walletnotify on node1 - self.extra_args = [["-blockversion=2", - "-alertnotify=echo > {}".format( - os.path.join(self.alertnotify_dir, '%s')), - "-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s'))], - ["-blockversion=211", - "-rescan", - "-walletnotify=echo > {}".format(os.path.join(self.walletnotify_dir, '%s'))]] + self.extra_args = [["-alertnotify=echo > {}".format( + os.path.join(self.alertnotify_dir, '%s')), + "-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s'))], + ["-blockversion=211", + "-rescan", + "-walletnotify=echo > {}".format(os.path.join(self.walletnotify_dir, '%s'))]] super().setup_network() def run_test(self): self.log.info("test -blocknotify") block_count = 10 - blocks = self.nodes[1].generate(block_count) + blocks = self.nodes[1].generatetoaddress( + block_count, + self.nodes[1].getnewaddress() if self.is_wallet_compiled() + else ADDRESS_BCHREG_UNSPENDABLE + ) # wait at most 10 seconds for expected number of files before reading # the content @@ -55,50 +56,51 @@ # directory content should equal the generated blocks hashes assert_equal(sorted(blocks), sorted(os.listdir(self.blocknotify_dir))) - self.log.info("test -walletnotify") - # wait at most 10 seconds for expected number of files before reading - # the content - wait_until( - lambda: len( - os.listdir( - self.walletnotify_dir)) == block_count, - timeout=10) - - # directory content should equal the generated transaction hashes - txids_rpc = list( - map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) - assert_equal( - sorted(txids_rpc), sorted( - os.listdir( - self.walletnotify_dir))) - for tx_file in os.listdir(self.walletnotify_dir): - os.remove(os.path.join(self.walletnotify_dir, tx_file)) - - self.log.info("test -walletnotify after rescan") - # restart node to rescan to force wallet notifications - self.restart_node(1) - connect_nodes_bi(self.nodes[0], self.nodes[1]) - - wait_until( - lambda: len( - os.listdir( - self.walletnotify_dir)) == block_count, - timeout=10) - - # directory content should equal the generated transaction hashes - txids_rpc = list( - map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) - assert_equal( - sorted(txids_rpc), sorted( - os.listdir( - self.walletnotify_dir))) + if self.is_wallet_compiled(): + self.log.info("test -walletnotify") + # wait at most 10 seconds for expected number of files before reading + # the content + wait_until( + lambda: len( + os.listdir( + self.walletnotify_dir)) == block_count, + timeout=10) + + # directory content should equal the generated transaction hashes + txids_rpc = list( + map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) + assert_equal( + sorted(txids_rpc), sorted( + os.listdir( + self.walletnotify_dir))) + for tx_file in os.listdir(self.walletnotify_dir): + os.remove(os.path.join(self.walletnotify_dir, tx_file)) + + self.log.info("test -walletnotify after rescan") + # restart node to rescan to force wallet notifications + self.restart_node(1) + connect_nodes_bi(self.nodes[0], self.nodes[1]) + + wait_until( + lambda: len( + os.listdir( + self.walletnotify_dir)) == block_count, + timeout=10) + + # directory content should equal the generated transaction hashes + txids_rpc = list( + map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) + assert_equal( + sorted(txids_rpc), sorted( + os.listdir( + self.walletnotify_dir))) # Create an invalid chain and ensure the node warns. self.log.info("test -alertnotify for forked chain") fork_block = self.nodes[0].getbestblockhash() - self.nodes[0].generate(1) + self.nodes[0].generatetoaddress(1, ADDRESS_BCHREG_UNSPENDABLE) invalid_block = self.nodes[0].getbestblockhash() - self.nodes[0].generate(7) + self.nodes[0].generatetoaddress(7, ADDRESS_BCHREG_UNSPENDABLE) # Invalidate a large branch, which should trigger an alert. self.nodes[0].invalidateblock(invalid_block) diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py --- a/test/functional/interface_bitcoin_cli.py +++ b/test/functional/interface_bitcoin_cli.py @@ -18,7 +18,6 @@ self.num_nodes = 1 def skip_test_if_missing_module(self): - self.skip_if_no_wallet() self.skip_if_no_cli() def run_test(self): @@ -29,9 +28,10 @@ self.log.info( "Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`") - cli_response = self.nodes[0].cli.getwalletinfo() - rpc_response = self.nodes[0].getwalletinfo() - assert_equal(cli_response, rpc_response) + if self.is_wallet_compiled(): + cli_response = self.nodes[0].cli.getwalletinfo() + rpc_response = self.nodes[0].getwalletinfo() + assert_equal(cli_response, rpc_response) self.log.info( "Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`") @@ -68,16 +68,18 @@ self.log.info( "Compare responses from `bitcoin-cli -getinfo` and the RPCs data is retrieved from.") cli_get_info = self.nodes[0].cli('-getinfo').send_cli() - wallet_info = self.nodes[0].getwalletinfo() + if self.is_wallet_compiled(): + wallet_info = self.nodes[0].getwalletinfo() network_info = self.nodes[0].getnetworkinfo() blockchain_info = self.nodes[0].getblockchaininfo() assert_equal(cli_get_info['version'], network_info['version']) assert_equal(cli_get_info['protocolversion'], network_info['protocolversion']) - assert_equal(cli_get_info['walletversion'], - wallet_info['walletversion']) - assert_equal(cli_get_info['balance'], wallet_info['balance']) + if self.is_wallet_compiled(): + assert_equal(cli_get_info['walletversion'], + wallet_info['walletversion']) + assert_equal(cli_get_info['balance'], wallet_info['balance']) assert_equal(cli_get_info['blocks'], blockchain_info['blocks']) assert_equal(cli_get_info['timeoffset'], network_info['timeoffset']) assert_equal(cli_get_info['connections'], network_info['connections']) @@ -86,13 +88,16 @@ assert_equal(cli_get_info['difficulty'], blockchain_info['difficulty']) assert_equal(cli_get_info['testnet'], blockchain_info['chain'] == "test") - assert_equal(cli_get_info['balance'], wallet_info['balance']) - assert_equal(cli_get_info['keypoololdest'], - wallet_info['keypoololdest']) - assert_equal(cli_get_info['keypoolsize'], wallet_info['keypoolsize']) - assert_equal(cli_get_info['paytxfee'], wallet_info['paytxfee']) - assert_equal(cli_get_info['relayfee'], network_info['relayfee']) - # unlocked_until is not tested because the wallet is not encrypted + if self.is_wallet_compiled(): + assert_equal(cli_get_info['balance'], wallet_info['balance']) + assert_equal(cli_get_info['keypoololdest'], + wallet_info['keypoololdest']) + assert_equal( + cli_get_info['keypoolsize'], + wallet_info['keypoolsize']) + assert_equal(cli_get_info['paytxfee'], wallet_info['paytxfee']) + assert_equal(cli_get_info['relayfee'], network_info['relayfee']) + # unlocked_until is not tested because the wallet is not encrypted if __name__ == '__main__': diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -6,6 +6,7 @@ import struct from io import BytesIO +from test_framework.address import ADDRESS_BCHREG_UNSPENDABLE from test_framework.test_framework import BitcoinTestFramework from test_framework.messages import CTransaction from test_framework.util import ( @@ -42,7 +43,6 @@ def skip_test_if_missing_module(self): self.skip_if_no_py3_zmq() self.skip_if_no_bitcoind_zmq() - self.skip_if_no_wallet() def setup_nodes(self): import zmq @@ -84,7 +84,8 @@ num_blocks = 5 self.log.info( "Generate {0} blocks (and {0} coinbase txes)".format(num_blocks)) - genhashes = self.nodes[0].generate(num_blocks) + genhashes = self.nodes[0].generatetoaddress( + num_blocks, ADDRESS_BCHREG_UNSPENDABLE) self.sync_all() for x in range(num_blocks): @@ -108,18 +109,19 @@ block = self.rawblock.receive() assert_equal(genhashes[x], hash256(block[:80]).hex()) - self.log.info("Wait for tx from second node") - payment_txid = self.nodes[1].sendtoaddress( - self.nodes[0].getnewaddress(), 1.0) - self.sync_all() + if self.is_wallet_compiled(): + self.log.info("Wait for tx from second node") + payment_txid = self.nodes[1].sendtoaddress( + self.nodes[0].getnewaddress(), 1.0) + self.sync_all() - # Should receive the broadcasted txid. - txid = self.hashtx.receive() - assert_equal(payment_txid, txid.hex()) + # Should receive the broadcasted txid. + txid = self.hashtx.receive() + assert_equal(payment_txid, txid.hex()) - # Should receive the broadcasted raw transaction. - hex = self.rawtx.receive() - assert_equal(payment_txid, hash256(hex).hex()) + # Should receive the broadcasted raw transaction. + hex = self.rawtx.receive() + assert_equal(payment_txid, hash256(hex).hex()) self.log.info("Test the getzmqnotifications RPC") assert_equal(self.nodes[0].getzmqnotifications(), [ diff --git a/test/functional/test_framework/address.py b/test/functional/test_framework/address.py --- a/test/functional/test_framework/address.py +++ b/test/functional/test_framework/address.py @@ -7,6 +7,8 @@ from .script import CScript, hash160, hash256 from .util import hex_str_to_bytes +ADDRESS_BCHREG_UNSPENDABLE = 'bchreg:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqha9s37tt' + chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'