Skip to content

Commit faa4043

Browse files
author
MarcoFalke
committed
qa: Run more tests with wallet disabled
1 parent 9f94483 commit faa4043

File tree

6 files changed

+63
-54
lines changed

6 files changed

+63
-54
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
- stage: test
122122
env: >-
123123
HOST=x86_64-unknown-linux-gnu
124-
PACKAGES="python3"
124+
PACKAGES="python3-zmq"
125125
DEP_OPTS="NO_WALLET=1"
126126
GOAL="install"
127127
BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"

test/functional/feature_config_args.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ def set_test_params(self):
1414
self.setup_clean_chain = True
1515
self.num_nodes = 1
1616

17-
def skip_test_if_missing_module(self):
18-
self.skip_if_no_wallet()
19-
2017
def test_config_file_parser(self):
2118
# Assume node is stopped
2219

@@ -68,13 +65,18 @@ def run_test(self):
6865
# Temporarily disabled, because this test would access the user's home dir (~/.bitcoin)
6966
#self.start_node(0, ['-conf='+conf_file, '-wallet=w1'])
7067
#self.stop_node(0)
68+
#assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'blocks'))
69+
#if self.is_wallet_compiled():
7170
#assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'wallets', 'w1'))
7271

7372
# Ensure command line argument overrides datadir in conf
7473
os.mkdir(new_data_dir_2)
7574
self.nodes[0].datadir = new_data_dir_2
7675
self.start_node(0, ['-datadir='+new_data_dir_2, '-conf='+conf_file, '-wallet=w2'])
77-
assert os.path.exists(os.path.join(new_data_dir_2, 'regtest', 'wallets', 'w2'))
76+
assert os.path.exists(os.path.join(new_data_dir_2, 'regtest', 'blocks'))
77+
if self.is_wallet_compiled():
78+
assert os.path.exists(os.path.join(new_data_dir_2, 'regtest', 'wallets', 'w2'))
79+
7880

7981
if __name__ == '__main__':
8082
ConfArgsTest().main()

test/functional/feature_notifications.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
"""Test the -alertnotify, -blocknotify and -walletnotify options."""
66
import os
77

8+
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
89
from test_framework.test_framework import BitcoinTestFramework
910
from test_framework.util import assert_equal, wait_until, connect_nodes_bi
1011

12+
1113
class NotificationsTest(BitcoinTestFramework):
1214
def set_test_params(self):
1315
self.num_nodes = 2
1416
self.setup_clean_chain = True
1517

16-
def skip_test_if_missing_module(self):
17-
self.skip_if_no_wallet()
18-
1918
def setup_network(self):
2019
self.alertnotify_dir = os.path.join(self.options.tmpdir, "alertnotify")
2120
self.blocknotify_dir = os.path.join(self.options.tmpdir, "blocknotify")
@@ -25,7 +24,7 @@ def setup_network(self):
2524
os.mkdir(self.walletnotify_dir)
2625

2726
# -alertnotify and -blocknotify on node0, walletnotify on node1
28-
self.extra_args = [["-blockversion=2",
27+
self.extra_args = [[
2928
"-alertnotify=echo > {}".format(os.path.join(self.alertnotify_dir, '%s')),
3029
"-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s'))],
3130
["-blockversion=211",
@@ -36,38 +35,39 @@ def setup_network(self):
3635
def run_test(self):
3736
self.log.info("test -blocknotify")
3837
block_count = 10
39-
blocks = self.nodes[1].generate(block_count)
38+
blocks = self.nodes[1].generatetoaddress(block_count, self.nodes[1].getnewaddress() if self.is_wallet_compiled() else ADDRESS_BCRT1_UNSPENDABLE)
4039

4140
# wait at most 10 seconds for expected number of files before reading the content
4241
wait_until(lambda: len(os.listdir(self.blocknotify_dir)) == block_count, timeout=10)
4342

4443
# directory content should equal the generated blocks hashes
4544
assert_equal(sorted(blocks), sorted(os.listdir(self.blocknotify_dir)))
4645

47-
self.log.info("test -walletnotify")
48-
# wait at most 10 seconds for expected number of files before reading the content
49-
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
46+
if self.is_wallet_compiled():
47+
self.log.info("test -walletnotify")
48+
# wait at most 10 seconds for expected number of files before reading the content
49+
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
5050

51-
# directory content should equal the generated transaction hashes
52-
txids_rpc = list(map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count)))
53-
assert_equal(sorted(txids_rpc), sorted(os.listdir(self.walletnotify_dir)))
54-
for tx_file in os.listdir(self.walletnotify_dir):
55-
os.remove(os.path.join(self.walletnotify_dir, tx_file))
51+
# directory content should equal the generated transaction hashes
52+
txids_rpc = list(map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count)))
53+
assert_equal(sorted(txids_rpc), sorted(os.listdir(self.walletnotify_dir)))
54+
for tx_file in os.listdir(self.walletnotify_dir):
55+
os.remove(os.path.join(self.walletnotify_dir, tx_file))
5656

57-
self.log.info("test -walletnotify after rescan")
58-
# restart node to rescan to force wallet notifications
59-
self.restart_node(1)
60-
connect_nodes_bi(self.nodes, 0, 1)
57+
self.log.info("test -walletnotify after rescan")
58+
# restart node to rescan to force wallet notifications
59+
self.restart_node(1)
60+
connect_nodes_bi(self.nodes, 0, 1)
6161

62-
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
62+
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
6363

64-
# directory content should equal the generated transaction hashes
65-
txids_rpc = list(map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count)))
66-
assert_equal(sorted(txids_rpc), sorted(os.listdir(self.walletnotify_dir)))
64+
# directory content should equal the generated transaction hashes
65+
txids_rpc = list(map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count)))
66+
assert_equal(sorted(txids_rpc), sorted(os.listdir(self.walletnotify_dir)))
6767

6868
# Mine another 41 up-version blocks. -alertnotify should trigger on the 51st.
6969
self.log.info("test -alertnotify")
70-
self.nodes[1].generate(41)
70+
self.nodes[1].generatetoaddress(41, ADDRESS_BCRT1_UNSPENDABLE)
7171
self.sync_all()
7272

7373
# Give bitcoind 10 seconds to write the alert notification
@@ -77,7 +77,7 @@ def run_test(self):
7777
os.remove(os.path.join(self.alertnotify_dir, notify_file))
7878

7979
# Mine more up-version blocks, should not get more alerts:
80-
self.nodes[1].generate(2)
80+
self.nodes[1].generatetoaddress(2, ADDRESS_BCRT1_UNSPENDABLE)
8181
self.sync_all()
8282

8383
self.log.info("-alertnotify should not continue notifying for more unknown version blocks")

test/functional/interface_bitcoin_cli.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ def set_test_params(self):
1212
self.setup_clean_chain = True
1313
self.num_nodes = 1
1414

15-
def skip_test_if_missing_module(self):
16-
self.skip_if_no_wallet()
17-
1815
def run_test(self):
1916
"""Main test logic"""
2017

2118
cli_response = self.nodes[0].cli("-version").send_cli()
2219
assert("Bitcoin Core RPC client version" in cli_response)
2320

2421
self.log.info("Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`")
25-
cli_response = self.nodes[0].cli.getwalletinfo()
26-
rpc_response = self.nodes[0].getwalletinfo()
27-
assert_equal(cli_response, rpc_response)
22+
if self.is_wallet_compiled():
23+
cli_response = self.nodes[0].cli.getwalletinfo()
24+
rpc_response = self.nodes[0].getwalletinfo()
25+
assert_equal(cli_response, rpc_response)
2826

2927
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`")
3028
cli_response = self.nodes[0].cli.getblockchaininfo()
@@ -52,26 +50,30 @@ def run_test(self):
5250

5351
self.log.info("Compare responses from `bitcoin-cli -getinfo` and the RPCs data is retrieved from.")
5452
cli_get_info = self.nodes[0].cli('-getinfo').send_cli()
55-
wallet_info = self.nodes[0].getwalletinfo()
53+
if self.is_wallet_compiled():
54+
wallet_info = self.nodes[0].getwalletinfo()
5655
network_info = self.nodes[0].getnetworkinfo()
5756
blockchain_info = self.nodes[0].getblockchaininfo()
5857

5958
assert_equal(cli_get_info['version'], network_info['version'])
6059
assert_equal(cli_get_info['protocolversion'], network_info['protocolversion'])
61-
assert_equal(cli_get_info['walletversion'], wallet_info['walletversion'])
62-
assert_equal(cli_get_info['balance'], wallet_info['balance'])
60+
if self.is_wallet_compiled():
61+
assert_equal(cli_get_info['walletversion'], wallet_info['walletversion'])
62+
assert_equal(cli_get_info['balance'], wallet_info['balance'])
6363
assert_equal(cli_get_info['blocks'], blockchain_info['blocks'])
6464
assert_equal(cli_get_info['timeoffset'], network_info['timeoffset'])
6565
assert_equal(cli_get_info['connections'], network_info['connections'])
6666
assert_equal(cli_get_info['proxy'], network_info['networks'][0]['proxy'])
6767
assert_equal(cli_get_info['difficulty'], blockchain_info['difficulty'])
6868
assert_equal(cli_get_info['testnet'], blockchain_info['chain'] == "test")
69-
assert_equal(cli_get_info['balance'], wallet_info['balance'])
70-
assert_equal(cli_get_info['keypoololdest'], wallet_info['keypoololdest'])
71-
assert_equal(cli_get_info['keypoolsize'], wallet_info['keypoolsize'])
72-
assert_equal(cli_get_info['paytxfee'], wallet_info['paytxfee'])
73-
assert_equal(cli_get_info['relayfee'], network_info['relayfee'])
74-
# unlocked_until is not tested because the wallet is not encrypted
69+
if self.is_wallet_compiled():
70+
assert_equal(cli_get_info['balance'], wallet_info['balance'])
71+
assert_equal(cli_get_info['keypoololdest'], wallet_info['keypoololdest'])
72+
assert_equal(cli_get_info['keypoolsize'], wallet_info['keypoolsize'])
73+
assert_equal(cli_get_info['paytxfee'], wallet_info['paytxfee'])
74+
assert_equal(cli_get_info['relayfee'], network_info['relayfee'])
75+
# unlocked_until is not tested because the wallet is not encrypted
76+
7577

7678
if __name__ == '__main__':
7779
TestBitcoinCli().main()

test/functional/interface_zmq.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""Test the ZMQ notification interface."""
66
import struct
77

8+
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
89
from test_framework.test_framework import BitcoinTestFramework
910
from test_framework.messages import CTransaction
1011
from test_framework.util import (
@@ -41,7 +42,6 @@ def set_test_params(self):
4142
def skip_test_if_missing_module(self):
4243
self.skip_if_no_py3_zmq()
4344
self.skip_if_no_bitcoind_zmq()
44-
self.skip_if_no_wallet()
4545

4646
def setup_nodes(self):
4747
import zmq
@@ -81,7 +81,7 @@ def run_test(self):
8181
def _zmq_test(self):
8282
num_blocks = 5
8383
self.log.info("Generate %(n)d blocks (and %(n)d coinbase txes)" % {"n": num_blocks})
84-
genhashes = self.nodes[0].generate(num_blocks)
84+
genhashes = self.nodes[0].generatetoaddress(num_blocks, ADDRESS_BCRT1_UNSPENDABLE)
8585
self.sync_all()
8686

8787
for x in range(num_blocks):
@@ -105,17 +105,19 @@ def _zmq_test(self):
105105
block = self.rawblock.receive()
106106
assert_equal(genhashes[x], bytes_to_hex_str(hash256(block[:80])))
107107

108-
self.log.info("Wait for tx from second node")
109-
payment_txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.0)
110-
self.sync_all()
108+
if self.is_wallet_compiled():
109+
self.log.info("Wait for tx from second node")
110+
payment_txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.0)
111+
self.sync_all()
112+
113+
# Should receive the broadcasted txid.
114+
txid = self.hashtx.receive()
115+
assert_equal(payment_txid, bytes_to_hex_str(txid))
111116

112-
# Should receive the broadcasted txid.
113-
txid = self.hashtx.receive()
114-
assert_equal(payment_txid, bytes_to_hex_str(txid))
117+
# Should receive the broadcasted raw transaction.
118+
hex = self.rawtx.receive()
119+
assert_equal(payment_txid, bytes_to_hex_str(hash256(hex)))
115120

116-
# Should receive the broadcasted raw transaction.
117-
hex = self.rawtx.receive()
118-
assert_equal(payment_txid, bytes_to_hex_str(hash256(hex)))
119121

120122
if __name__ == '__main__':
121123
ZMQTest().main()

test/functional/test_framework/address.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
from . import segwit_addr
1111

12+
ADDRESS_BCRT1_UNSPENDABLE = 'bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj'
13+
1214
chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
1315

16+
1417
def byte_to_base58(b, version):
1518
result = ''
1619
str = bytes_to_hex_str(b)

0 commit comments

Comments
 (0)