qa: Run more tests with wallet disabled

This commit is contained in:
MarcoFalke 2018-09-23 11:34:51 -04:00
parent 9f94483b7a
commit faa4043c66
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
6 changed files with 63 additions and 54 deletions

View File

@ -121,7 +121,7 @@ jobs:
- stage: test - stage: test
env: >- env: >-
HOST=x86_64-unknown-linux-gnu HOST=x86_64-unknown-linux-gnu
PACKAGES="python3" PACKAGES="python3-zmq"
DEP_OPTS="NO_WALLET=1" DEP_OPTS="NO_WALLET=1"
GOAL="install" GOAL="install"
BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"

View File

@ -14,9 +14,6 @@ class ConfArgsTest(BitcoinTestFramework):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 1 self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def test_config_file_parser(self): def test_config_file_parser(self):
# Assume node is stopped # Assume node is stopped
@ -68,13 +65,18 @@ class ConfArgsTest(BitcoinTestFramework):
# Temporarily disabled, because this test would access the user's home dir (~/.bitcoin) # Temporarily disabled, because this test would access the user's home dir (~/.bitcoin)
#self.start_node(0, ['-conf='+conf_file, '-wallet=w1']) #self.start_node(0, ['-conf='+conf_file, '-wallet=w1'])
#self.stop_node(0) #self.stop_node(0)
#assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'blocks'))
#if self.is_wallet_compiled():
#assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'wallets', 'w1')) #assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'wallets', 'w1'))
# Ensure command line argument overrides datadir in conf # Ensure command line argument overrides datadir in conf
os.mkdir(new_data_dir_2) os.mkdir(new_data_dir_2)
self.nodes[0].datadir = new_data_dir_2 self.nodes[0].datadir = new_data_dir_2
self.start_node(0, ['-datadir='+new_data_dir_2, '-conf='+conf_file, '-wallet=w2']) 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__': if __name__ == '__main__':
ConfArgsTest().main() ConfArgsTest().main()

View File

@ -5,17 +5,16 @@
"""Test the -alertnotify, -blocknotify and -walletnotify options.""" """Test the -alertnotify, -blocknotify and -walletnotify options."""
import os import os
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, wait_until, connect_nodes_bi from test_framework.util import assert_equal, wait_until, connect_nodes_bi
class NotificationsTest(BitcoinTestFramework): class NotificationsTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 2 self.num_nodes = 2
self.setup_clean_chain = True self.setup_clean_chain = True
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def setup_network(self): def setup_network(self):
self.alertnotify_dir = os.path.join(self.options.tmpdir, "alertnotify") self.alertnotify_dir = os.path.join(self.options.tmpdir, "alertnotify")
self.blocknotify_dir = os.path.join(self.options.tmpdir, "blocknotify") self.blocknotify_dir = os.path.join(self.options.tmpdir, "blocknotify")
@ -25,7 +24,7 @@ class NotificationsTest(BitcoinTestFramework):
os.mkdir(self.walletnotify_dir) os.mkdir(self.walletnotify_dir)
# -alertnotify and -blocknotify on node0, walletnotify on node1 # -alertnotify and -blocknotify on node0, walletnotify on node1
self.extra_args = [["-blockversion=2", self.extra_args = [[
"-alertnotify=echo > {}".format(os.path.join(self.alertnotify_dir, '%s')), "-alertnotify=echo > {}".format(os.path.join(self.alertnotify_dir, '%s')),
"-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s'))], "-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s'))],
["-blockversion=211", ["-blockversion=211",
@ -36,7 +35,7 @@ class NotificationsTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("test -blocknotify") self.log.info("test -blocknotify")
block_count = 10 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_BCRT1_UNSPENDABLE)
# wait at most 10 seconds for expected number of files before reading the content # wait at most 10 seconds for expected number of files before reading the content
wait_until(lambda: len(os.listdir(self.blocknotify_dir)) == block_count, timeout=10) wait_until(lambda: len(os.listdir(self.blocknotify_dir)) == block_count, timeout=10)
@ -44,30 +43,31 @@ class NotificationsTest(BitcoinTestFramework):
# directory content should equal the generated blocks hashes # directory content should equal the generated blocks hashes
assert_equal(sorted(blocks), sorted(os.listdir(self.blocknotify_dir))) assert_equal(sorted(blocks), sorted(os.listdir(self.blocknotify_dir)))
self.log.info("test -walletnotify") if self.is_wallet_compiled():
# wait at most 10 seconds for expected number of files before reading the content self.log.info("test -walletnotify")
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10) # 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 # directory content should equal the generated transaction hashes
txids_rpc = list(map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) 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))) assert_equal(sorted(txids_rpc), sorted(os.listdir(self.walletnotify_dir)))
for tx_file in os.listdir(self.walletnotify_dir): for tx_file in os.listdir(self.walletnotify_dir):
os.remove(os.path.join(self.walletnotify_dir, tx_file)) os.remove(os.path.join(self.walletnotify_dir, tx_file))
self.log.info("test -walletnotify after rescan") self.log.info("test -walletnotify after rescan")
# restart node to rescan to force wallet notifications # restart node to rescan to force wallet notifications
self.restart_node(1) self.restart_node(1)
connect_nodes_bi(self.nodes, 0, 1) connect_nodes_bi(self.nodes, 0, 1)
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10) wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
# directory content should equal the generated transaction hashes # directory content should equal the generated transaction hashes
txids_rpc = list(map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) 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))) assert_equal(sorted(txids_rpc), sorted(os.listdir(self.walletnotify_dir)))
# Mine another 41 up-version blocks. -alertnotify should trigger on the 51st. # Mine another 41 up-version blocks. -alertnotify should trigger on the 51st.
self.log.info("test -alertnotify") self.log.info("test -alertnotify")
self.nodes[1].generate(41) self.nodes[1].generatetoaddress(41, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() self.sync_all()
# Give bitcoind 10 seconds to write the alert notification # Give bitcoind 10 seconds to write the alert notification
@ -77,7 +77,7 @@ class NotificationsTest(BitcoinTestFramework):
os.remove(os.path.join(self.alertnotify_dir, notify_file)) os.remove(os.path.join(self.alertnotify_dir, notify_file))
# Mine more up-version blocks, should not get more alerts: # Mine more up-version blocks, should not get more alerts:
self.nodes[1].generate(2) self.nodes[1].generatetoaddress(2, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() self.sync_all()
self.log.info("-alertnotify should not continue notifying for more unknown version blocks") self.log.info("-alertnotify should not continue notifying for more unknown version blocks")

View File

@ -12,9 +12,6 @@ class TestBitcoinCli(BitcoinTestFramework):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 1 self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def run_test(self): def run_test(self):
"""Main test logic""" """Main test logic"""
@ -22,9 +19,10 @@ class TestBitcoinCli(BitcoinTestFramework):
assert("Bitcoin Core RPC client version" in cli_response) assert("Bitcoin Core RPC client version" in cli_response)
self.log.info("Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`") self.log.info("Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`")
cli_response = self.nodes[0].cli.getwalletinfo() if self.is_wallet_compiled():
rpc_response = self.nodes[0].getwalletinfo() cli_response = self.nodes[0].cli.getwalletinfo()
assert_equal(cli_response, rpc_response) rpc_response = self.nodes[0].getwalletinfo()
assert_equal(cli_response, rpc_response)
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`") self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`")
cli_response = self.nodes[0].cli.getblockchaininfo() cli_response = self.nodes[0].cli.getblockchaininfo()
@ -52,26 +50,30 @@ class TestBitcoinCli(BitcoinTestFramework):
self.log.info("Compare responses from `bitcoin-cli -getinfo` and the RPCs data is retrieved from.") 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() 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() network_info = self.nodes[0].getnetworkinfo()
blockchain_info = self.nodes[0].getblockchaininfo() blockchain_info = self.nodes[0].getblockchaininfo()
assert_equal(cli_get_info['version'], network_info['version']) assert_equal(cli_get_info['version'], network_info['version'])
assert_equal(cli_get_info['protocolversion'], network_info['protocolversion']) assert_equal(cli_get_info['protocolversion'], network_info['protocolversion'])
assert_equal(cli_get_info['walletversion'], wallet_info['walletversion']) if self.is_wallet_compiled():
assert_equal(cli_get_info['balance'], wallet_info['balance']) 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['blocks'], blockchain_info['blocks'])
assert_equal(cli_get_info['timeoffset'], network_info['timeoffset']) assert_equal(cli_get_info['timeoffset'], network_info['timeoffset'])
assert_equal(cli_get_info['connections'], network_info['connections']) assert_equal(cli_get_info['connections'], network_info['connections'])
assert_equal(cli_get_info['proxy'], network_info['networks'][0]['proxy']) assert_equal(cli_get_info['proxy'], network_info['networks'][0]['proxy'])
assert_equal(cli_get_info['difficulty'], blockchain_info['difficulty']) assert_equal(cli_get_info['difficulty'], blockchain_info['difficulty'])
assert_equal(cli_get_info['testnet'], blockchain_info['chain'] == "test") assert_equal(cli_get_info['testnet'], blockchain_info['chain'] == "test")
assert_equal(cli_get_info['balance'], wallet_info['balance']) if self.is_wallet_compiled():
assert_equal(cli_get_info['keypoololdest'], wallet_info['keypoololdest']) assert_equal(cli_get_info['balance'], wallet_info['balance'])
assert_equal(cli_get_info['keypoolsize'], wallet_info['keypoolsize']) assert_equal(cli_get_info['keypoololdest'], wallet_info['keypoololdest'])
assert_equal(cli_get_info['paytxfee'], wallet_info['paytxfee']) assert_equal(cli_get_info['keypoolsize'], wallet_info['keypoolsize'])
assert_equal(cli_get_info['relayfee'], network_info['relayfee']) assert_equal(cli_get_info['paytxfee'], wallet_info['paytxfee'])
# unlocked_until is not tested because the wallet is not encrypted assert_equal(cli_get_info['relayfee'], network_info['relayfee'])
# unlocked_until is not tested because the wallet is not encrypted
if __name__ == '__main__': if __name__ == '__main__':
TestBitcoinCli().main() TestBitcoinCli().main()

View File

@ -5,6 +5,7 @@
"""Test the ZMQ notification interface.""" """Test the ZMQ notification interface."""
import struct import struct
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import CTransaction from test_framework.messages import CTransaction
from test_framework.util import ( from test_framework.util import (
@ -41,7 +42,6 @@ class ZMQTest (BitcoinTestFramework):
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_py3_zmq() self.skip_if_no_py3_zmq()
self.skip_if_no_bitcoind_zmq() self.skip_if_no_bitcoind_zmq()
self.skip_if_no_wallet()
def setup_nodes(self): def setup_nodes(self):
import zmq import zmq
@ -81,7 +81,7 @@ class ZMQTest (BitcoinTestFramework):
def _zmq_test(self): def _zmq_test(self):
num_blocks = 5 num_blocks = 5
self.log.info("Generate %(n)d blocks (and %(n)d coinbase txes)" % {"n": num_blocks}) self.log.info("Generate %(n)d blocks (and %(n)d coinbase txes)" % {"n": num_blocks})
genhashes = self.nodes[0].generate(num_blocks) genhashes = self.nodes[0].generatetoaddress(num_blocks, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() self.sync_all()
for x in range(num_blocks): for x in range(num_blocks):
@ -105,17 +105,19 @@ class ZMQTest (BitcoinTestFramework):
block = self.rawblock.receive() block = self.rawblock.receive()
assert_equal(genhashes[x], bytes_to_hex_str(hash256(block[:80]))) assert_equal(genhashes[x], bytes_to_hex_str(hash256(block[:80])))
self.log.info("Wait for tx from second node") if self.is_wallet_compiled():
payment_txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.0) self.log.info("Wait for tx from second node")
self.sync_all() payment_txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.0)
self.sync_all()
# Should receive the broadcasted txid. # Should receive the broadcasted txid.
txid = self.hashtx.receive() txid = self.hashtx.receive()
assert_equal(payment_txid, bytes_to_hex_str(txid)) assert_equal(payment_txid, bytes_to_hex_str(txid))
# Should receive the broadcasted raw transaction.
hex = self.rawtx.receive()
assert_equal(payment_txid, bytes_to_hex_str(hash256(hex)))
# Should receive the broadcasted raw transaction.
hex = self.rawtx.receive()
assert_equal(payment_txid, bytes_to_hex_str(hash256(hex)))
if __name__ == '__main__': if __name__ == '__main__':
ZMQTest().main() ZMQTest().main()

View File

@ -9,8 +9,11 @@ from .util import bytes_to_hex_str, hex_str_to_bytes
from . import segwit_addr from . import segwit_addr
ADDRESS_BCRT1_UNSPENDABLE = 'bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj'
chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def byte_to_base58(b, version): def byte_to_base58(b, version):
result = '' result = ''
str = bytes_to_hex_str(b) str = bytes_to_hex_str(b)