in progress on making py tests run

This commit is contained in:
Brannon King 2019-08-30 09:28:43 -06:00 committed by Anthony Fieroni
parent 5dca394aaa
commit 17875c97c9
29 changed files with 139 additions and 102 deletions

View file

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef CLAIMSCRIPTOP_H
#define CLAIMSCRIPTOP_H
#ifndef BITCOIN_CLAIMSCRIPTOP_H
#define BITCOIN_CLAIMSCRIPTOP_H
#include <amount.h>
#include <claimtrie/forks.h>
@ -242,4 +242,4 @@ struct CUpdateCacheCallbacks
*/
void UpdateCache(const CTransaction& tx, CClaimTrieCache& trieCache, const CCoinsViewCache& view, int nHeight, const CUpdateCacheCallbacks& callbacks = {});
#endif // CLAIMSCRIPTOP_H
#endif // BITCOIN_CLAIMSCRIPTOP_H

View file

@ -1,5 +1,5 @@
#ifndef LBRY_H
#define LBRY_H
#ifndef BITCOIN_LBRY_H
#define BITCOIN_LBRY_H
#include <chain.h>
#include <chainparams.h>

View file

@ -16,6 +16,6 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
# Which components are enabled. These are commented out by `configure` if they were disabled when running config.
@ENABLE_WALLET_TRUE@ENABLE_WALLET=true
@BUILD_BITCOIN_CLI_TRUE@ENABLE_CLI=true
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=true
@BUILD_BITCOIND_TRUE@ENABLE_LBRYCRDD=true
@ENABLE_FUZZ_TRUE@ENABLE_FUZZ=true
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true

View file

@ -357,7 +357,7 @@ class FullBlockTest(BitcoinTestFramework):
b26 = self.update_block(26, [])
self.send_blocks([b26], success=False, reject_reason='bad-cb-length', reconnect=True)
# Extend the b26 chain to make sure bitcoind isn't accepting b26
# Extend the b26 chain to make sure lbrycrdd isn't accepting b26
b27 = self.next_block(27, spend=out[7])
self.send_blocks([b27], False)
@ -369,7 +369,7 @@ class FullBlockTest(BitcoinTestFramework):
b28 = self.update_block(28, [])
self.send_blocks([b28], success=False, reject_reason='bad-cb-length', reconnect=True)
# Extend the b28 chain to make sure bitcoind isn't accepting b28
# Extend the b28 chain to make sure lbrycrdd isn't accepting b28
b29 = self.next_block(29, spend=out[7])
self.send_blocks([b29], False)
@ -909,7 +909,7 @@ class FullBlockTest(BitcoinTestFramework):
assert_equal(len(b64a.serialize()), MAX_BLOCK_BASE_SIZE + 8)
self.send_blocks([b64a], success=False, reject_reason='non-canonical ReadCompactSize()')
# bitcoind doesn't disconnect us for sending a bloated block, but if we subsequently
# lbrycrdd doesn't disconnect us for sending a bloated block, but if we subsequently
# resend the header message, it won't send us the getdata message again. Just
# disconnect and reconnect and then call sync_blocks.
# TODO: improve this test to be less dependent on P2P DOS behaviour.

View file

@ -21,7 +21,7 @@ class ConfArgsTest(BitcoinTestFramework):
# Assume node is stopped
inc_conf_file_path = os.path.join(self.nodes[0].datadir, 'include.conf')
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
with open(os.path.join(self.nodes[0].datadir, 'lbrycrd.conf'), 'a', encoding='utf-8') as conf:
conf.write('includeconf={}\n'.format(inc_conf_file_path))
self.nodes[0].assert_start_raises_init_error(
@ -104,7 +104,7 @@ class ConfArgsTest(BitcoinTestFramework):
self.nodes[0].assert_start_raises_init_error(['-datadir=' + new_data_dir], 'Error: Specified data directory "' + new_data_dir + '" does not exist.')
# Check that using non-existent datadir in conf file fails
conf_file = os.path.join(default_data_dir, "bitcoin.conf")
conf_file = os.path.join(default_data_dir, "lbrycrd.conf")
# datadir needs to be set before [regtest] section
conf_file_contents = open(conf_file, encoding='utf8').read()

View file

@ -93,14 +93,14 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
return utxo_hash
except:
# An exception here should mean the node is about to crash.
# If bitcoind exits, then try again. wait_for_node_exit()
# should raise an exception if bitcoind doesn't exit.
# If lbrycrdd exits, then try again. wait_for_node_exit()
# should raise an exception if lbrycrdd doesn't exit.
self.wait_for_node_exit(node_index, timeout=10)
self.crashed_on_restart += 1
time.sleep(1)
# If we got here, bitcoind isn't coming back up on restart. Could be a
# bug in bitcoind, or we've gotten unlucky with our dbcrash ratio --
# If we got here, lbrycrdd isn't coming back up on restart. Could be a
# bug in lbrycrdd, or we've gotten unlucky with our dbcrash ratio --
# perhaps we generated a test case that blew up our cache?
# TODO: If this happens a lot, we should try to restart without -dbcrashratio
# and make sure that recovery happens.

View file

@ -32,7 +32,7 @@ class IncludeConfTest(BitcoinTestFramework):
# - tmpdir/node0/relative2.conf
with open(os.path.join(self.options.tmpdir, "node0", "relative2.conf"), "w", encoding="utf8") as f:
f.write("uacomment=relative2\n")
with open(os.path.join(self.options.tmpdir, "node0", "bitcoin.conf"), "a", encoding='utf8') as f:
with open(os.path.join(self.options.tmpdir, "node0", "lbrycrd.conf"), "a", encoding='utf8') as f:
f.write("uacomment=main\nincludeconf=relative.conf\n")
def run_test(self):
@ -70,7 +70,7 @@ class IncludeConfTest(BitcoinTestFramework):
# Restore initial file contents
f.write("uacomment=relative\n")
with open(os.path.join(self.options.tmpdir, "node0", "bitcoin.conf"), "a", encoding='utf8') as f:
with open(os.path.join(self.options.tmpdir, "node0", "lbrycrd.conf"), "a", encoding='utf8') as f:
f.write("includeconf=relative2.conf\n")
self.start_node(0)

View file

@ -2,13 +2,13 @@
# Copyright (c) 2015-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test bitcoind with different proxy configuration.
"""Test lbrycrdd with different proxy configuration.
Test plan:
- Start bitcoind's with different proxy configurations
- Start lbrycrdd's with different proxy configurations
- Use addnode to initiate connections
- Verify that proxies are connected to, and the right connection command is given
- Proxy configurations to test on bitcoind side:
- Proxy configurations to test on lbrycrdd side:
- `-proxy` (proxy everything)
- `-onion` (proxy just onions)
- `-proxyrandomize` Circuit randomization
@ -18,8 +18,8 @@ Test plan:
- proxy on IPv6
- Create various proxies (as threads)
- Create bitcoinds that connect to them
- Manipulate the bitcoinds using addnode (onetry) an observe effects
- Create lbrycrdds that connect to them
- Manipulate the lbrycrdds using addnode (onetry) an observe effects
addnode connect to IPv4
addnode connect to IPv6
@ -96,7 +96,7 @@ class ProxyTest(BitcoinTestFramework):
node.addnode("15.61.23.23:1234", "onetry")
cmd = proxies[0].queue.get()
assert isinstance(cmd, Socks5Command)
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
# Note: lbrycrdd's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
assert_equal(cmd.addr, b"15.61.23.23")
assert_equal(cmd.port, 1234)
@ -110,7 +110,7 @@ class ProxyTest(BitcoinTestFramework):
node.addnode("[1233:3432:2434:2343:3234:2345:6546:4534]:5443", "onetry")
cmd = proxies[1].queue.get()
assert isinstance(cmd, Socks5Command)
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
# Note: lbrycrdd's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534")
assert_equal(cmd.port, 5443)

View file

@ -2,7 +2,7 @@
# Copyright (c) 2014-2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test running bitcoind with -reindex and -reindex-chainstate options.
"""Test running lbrycrdd with -reindex and -reindex-chainstate options.
- Start a single node and generate 3 blocks.
- Stop the node and restart it with -reindex. Verify that the node has reindexed up to block 3.

View file

@ -89,7 +89,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
# is cleared. This will move the versionbit state to ACTIVE.
node.generatetoaddress(VB_PERIOD, node_deterministic_address)
# Stop-start the node. This is required because bitcoind will only warn once about unknown versions or unknown rules activating.
# Stop-start the node. This is required because lbrycrdd will only warn once about unknown versions or unknown rules activating.
self.restart_node(0)
# Generating one block guarantees that we'll get out of IBD

View file

@ -88,7 +88,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
assert b'"error":null' in out1
assert conn.sock is not None #connection must be closed because bitcoind should use keep-alive by default
assert conn.sock is not None #connection must be closed because lbrycrdd should use keep-alive by default
# Check excessive request size
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)

View file

@ -42,7 +42,7 @@ class ZMQTest (BitcoinTestFramework):
def skip_test_if_missing_module(self):
self.skip_if_no_py3_zmq()
self.skip_if_no_bitcoind_zmq()
self.skip_if_no_lbrycrdd_zmq()
self.skip_if_no_wallet()
def setup_nodes(self):
@ -67,7 +67,7 @@ class ZMQTest (BitcoinTestFramework):
# Invalid zmq arguments don't take down the node, see #17185.
self.restart_node(0, ["-zmqpubrawtx=foo", "-zmqpubhashtx=bar"])
address = 'tcp://127.0.0.1:28332'
address = 'tcp://127.0.0.1:29245'
socket = self.ctx.socket(zmq.SUB)
socket.set(zmq.RCVTIMEO, 60000)

View file

@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mempool persistence.
By default, bitcoind will dump mempool on shutdown and
By default, lbrycrdd will dump mempool on shutdown and
then reload it on startup. This can be overridden with
the -persistmempool=0 command line option.
@ -123,7 +123,7 @@ class MempoolPersistTest(BitcoinTestFramework):
wait_until(lambda: self.nodes[1].getmempoolinfo()["loaded"])
assert_equal(len(self.nodes[1].getrawmempool()), 5)
self.log.debug("Prevent bitcoind from writing mempool.dat to disk. Verify that `savemempool` fails")
self.log.debug("Prevent lbrycrdd from writing mempool.dat to disk. Verify that `savemempool` fails")
# to test the exception we are creating a tmp folder called mempool.dat.new
# which is an implementation detail that could change and break this test
mempooldotnew1 = mempooldat1 + '.new'

View file

@ -16,7 +16,7 @@ from test_framework.script import CScript, OP_TRUE, OP_DROP
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, wait_until, softfork_active
# TestP2PConn: A peer we use to send messages to bitcoind, and store responses.
# TestP2PConn: A peer we use to send messages to lbrycrdd, and store responses.
class TestP2PConn(P2PInterface):
def __init__(self, cmpct_version):
super().__init__()
@ -241,7 +241,7 @@ class CompactBlocksTest(BitcoinTestFramework):
old_node.request_headers_and_sync(locator=[tip])
check_announcement_of_new_block(node, old_node, lambda p: "cmpctblock" in p.last_message)
# This test actually causes bitcoind to (reasonably!) disconnect us, so do this last.
# This test actually causes lbrycrdd to (reasonably!) disconnect us, so do this last.
def test_invalid_cmpctblock_message(self):
self.nodes[0].generate(101)
block = self.build_block_on_tip(self.nodes[0])
@ -256,7 +256,7 @@ class CompactBlocksTest(BitcoinTestFramework):
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.hashPrevBlock)
# Compare the generated shortids to what we expect based on BIP 152, given
# bitcoind's choice of nonce.
# lbrycrdd's choice of nonce.
def test_compactblock_construction(self, test_node, use_witness_address=True):
version = test_node.cmpct_version
node = self.nodes[0]
@ -365,7 +365,7 @@ class CompactBlocksTest(BitcoinTestFramework):
header_and_shortids.shortids.pop(0)
index += 1
# Test that bitcoind requests compact blocks when we announce new blocks
# Test that lbrycrdd requests compact blocks when we announce new blocks
# via header or inv, and that responding to getblocktxn causes the block
# to be successfully reconstructed.
# Post-segwit: upgraded nodes would only make this request of cb-version-2,
@ -550,7 +550,7 @@ class CompactBlocksTest(BitcoinTestFramework):
assert_equal(absolute_indexes, [6, 7, 8, 9, 10])
# Now give an incorrect response.
# Note that it's possible for bitcoind to be smart enough to know we're
# Note that it's possible for lbrycrdd to be smart enough to know we're
# lying, since it could check to see if the shortid matches what we're
# sending, and eg disconnect us for misbehavior. If that behavior
# change was made, we could just modify this test by having a
@ -580,9 +580,9 @@ class CompactBlocksTest(BitcoinTestFramework):
assert_equal(int(node.getbestblockhash(), 16), block.sha256)
def test_getblocktxn_handler(self, test_node):
# lbrycrdd will not send blocktxn responses for blocks whose height is
version = test_node.cmpct_version
node = self.nodes[0]
# bitcoind will not send blocktxn responses for blocks whose height is
# more than 10 blocks deep.
MAX_GETBLOCKTXN_DEPTH = 10
chain_height = node.getblockcount()

View file

@ -58,7 +58,7 @@ class CLazyNode(P2PInterface):
# anyway, and eventually get disconnected.
class CNodeNoVersionBan(CLazyNode):
# send a bunch of veracks without sending a message. This should get us disconnected.
# NOTE: implementation-specific check here. Remove if bitcoind ban behavior changes
# NOTE: implementation-specific check here. Remove if lbrycrdd ban behavior changes
def on_open(self):
super().on_open()
for i in range(banscore):

View file

@ -723,7 +723,7 @@ class SegWitTest(BitcoinTestFramework):
# This transaction should not be accepted into the mempool pre- or
# post-segwit. Mempool acceptance will use SCRIPT_VERIFY_WITNESS which
# will require a witness to spend a witness program regardless of
# segwit activation. Note that older bitcoind's that are not
# segwit activation. Note that older lbrycrdd's that are not
# segwit-aware would also reject this for failing CLEANSTACK.
with self.nodes[0].assert_debug_log(
expected_msgs=(spend_tx.hash, 'was not accepted: non-mandatory-script-verify-flag (Witness program was passed an empty witness)')):
@ -979,7 +979,7 @@ class SegWitTest(BitcoinTestFramework):
self.nodes[0].submitblock(block.serialize().hex())
assert self.nodes[0].getbestblockhash() != block.hash
# Now redo commitment with the standard nonce, but let bitcoind fill it in.
# Now redo commitment with the standard nonce, but let lbrycrdd fill it in.
add_witness_commitment(block, nonce=0)
block.vtx[0].wit = CTxWitness()
block.solve()

View file

@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test various net timeouts.
- Create three bitcoind nodes:
- Create three lbrycrdd nodes:
no_verack_node - we never send a verack in response to their version
no_version_node - we never send a version (only a ping)

View file

@ -2,7 +2,7 @@
# Copyright (c) 2014-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test running bitcoind with the -rpcbind and -rpcallowip options."""
"""Test running lbrycrdd with the -rpcbind and -rpcallowip options."""
import sys

View file

@ -38,7 +38,7 @@ class HTTPBasicsTest(BitcoinTestFramework):
def setup_chain(self):
super().setup_chain()
#Append rpcauth to bitcoin.conf before initialization
#Append rpcauth to lbrycrd.conf before initialization
self.rtpassword = "cA773lm788buwYe4g4WT+05pKyNruVKjQ25x3n0DQcM="
rpcauth = "rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144"
@ -62,11 +62,11 @@ class HTTPBasicsTest(BitcoinTestFramework):
rpcauth3 = lines[1]
self.password = lines[3]
with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "bitcoin.conf"), 'a', encoding='utf8') as f:
with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "lbrycrd.conf"), 'a', encoding='utf8') as f:
f.write(rpcauth+"\n")
f.write(rpcauth2+"\n")
f.write(rpcauth3+"\n")
with open(os.path.join(get_datadir_path(self.options.tmpdir, 1), "bitcoin.conf"), 'a', encoding='utf8') as f:
with open(os.path.join(get_datadir_path(self.options.tmpdir, 1), "lbrycrd.conf"), 'a', encoding='utf8') as f:
f.write("rpcuser={}\n".format(self.rpcuser))
f.write("rpcpassword={}\n".format(self.rpcpassword))

View file

@ -19,7 +19,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""HTTP proxy for opening RPC connection to bitcoind.
"""HTTP proxy for opening RPC connection to lbrycrdd.
AuthServiceProxy has the following improvements over python-jsonrpc's
ServiceProxy class:

View file

@ -183,7 +183,7 @@ def FromHex(obj, hex_string):
def ToHex(obj):
return obj.serialize().hex()
# Objects that map to bitcoind objects, which can be serialized/deserialized
# Objects that map to lbrycrdd objects, which can be serialized/deserialized
class CAddress:
@ -441,7 +441,7 @@ class CTransaction:
if len(self.vin) == 0:
flags = struct.unpack("<B", f.read(1))[0]
# Not sure why flags can't be zero, but this
# matches the implementation in bitcoind
# matches the implementation in lbrycrdd
if (flags != 0):
self.vin = deser_vector(f, CTxIn)
self.vout = deser_vector(f, CTxOut)
@ -1304,7 +1304,7 @@ class msg_headers:
self.headers = headers if headers is not None else []
def deserialize(self, f):
# comment in bitcoind indicates these should be deserialized as blocks
# comment in lbrycrdd indicates these should be deserialized as blocks
blocks = deser_vector(f, CBlock)
for x in blocks:
self.headers.append(CBlockHeader(x))

View file

@ -114,9 +114,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true",
help="Leave bitcoinds and test.* datadir on exit or error")
help="Leave lbrycrdds and test.* datadir on exit or error")
parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true",
help="Don't stop bitcoinds after the test execution")
help="Don't stop lbrycrdds after the test execution")
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
help="Directory for caching pregenerated datadirs (default: %(default)s)")
parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
@ -134,7 +134,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
help="Attach a python debugger if test fails")
parser.add_argument("--usecli", dest="usecli", default=False, action="store_true",
help="use bitcoin-cli instead of RPC for all commands")
help="use lbrycrd-cli instead of RPC for all commands")
parser.add_argument("--perf", dest="perf", default=False, action="store_true",
help="profile running nodes with perf for the duration of the test")
parser.add_argument("--randomseed", type=int,
@ -151,8 +151,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
config = configparser.ConfigParser()
config.read_file(open(self.options.configfile))
self.config = config
self.options.bitcoind = os.getenv("BITCOIND", default=config["environment"]["BUILDDIR"] + '/src/bitcoind' + config["environment"]["EXEEXT"])
self.options.bitcoincli = os.getenv("BITCOINCLI", default=config["environment"]["BUILDDIR"] + '/src/bitcoin-cli' + config["environment"]["EXEEXT"])
self.options.lbrycrdd = os.getenv("LBRYCRDD", default=config["environment"]["BUILDDIR"] + '/src/lbrycrdd' + config["environment"]["EXEEXT"])
self.options.bitcoincli = os.getenv("LBRYCRDCLI", default=config["environment"]["BUILDDIR"] + '/src/lbrycrd-cli' + config["environment"]["EXEEXT"])
os.environ['PATH'] = os.pathsep.join([
os.path.join(config['environment']['BUILDDIR'], 'src'),
@ -227,7 +227,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
else:
for node in self.nodes:
node.cleanup_on_exit = False
self.log.info("Note: bitcoinds were not stopped and may still be running")
self.log.info("Note: lbrycrdds were not stopped and may still be running")
should_clean_up = (
not self.options.nocleanup and
@ -352,7 +352,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
if extra_args is None:
extra_args = [[]] * num_nodes
if binary is None:
binary = [self.options.bitcoind] * num_nodes
binary = [self.options.lbrycrdd] * num_nodes
assert_equal(len(extra_confs), num_nodes)
assert_equal(len(extra_args), num_nodes)
assert_equal(len(binary), num_nodes)
@ -363,7 +363,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
chain=self.chain,
rpchost=rpchost,
timewait=self.rpc_timeout,
bitcoind=binary[i],
lbrycrdd=binary[i],
bitcoin_cli=self.options.bitcoincli,
coverage_dir=self.options.coveragedir,
cwd=self.options.tmpdir,
@ -374,7 +374,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
))
def start_node(self, i, *args, **kwargs):
"""Start a bitcoind"""
"""Start a lbrycrdd"""
node = self.nodes[i]
@ -385,7 +385,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
def start_nodes(self, extra_args=None, *args, **kwargs):
"""Start multiple bitcoinds"""
"""Start multiple lbrycrdds"""
if extra_args is None:
extra_args = [None] * self.num_nodes
@ -405,12 +405,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
def stop_node(self, i, expected_stderr='', wait=0):
"""Stop a bitcoind test node"""
"""Stop a lbrycrdd test node"""
self.nodes[i].stop_node(expected_stderr, wait=wait)
self.nodes[i].wait_until_stopped()
def stop_nodes(self, wait=0):
"""Stop multiple bitcoind test nodes"""
"""Stop multiple lbrycrdd test nodes"""
for node in self.nodes:
# Issue RPC to stop nodes
node.stop_node(wait=wait)
@ -467,7 +467,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# User can provide log level as a number or string (eg DEBUG). loglevel was caught as a string, so try to convert it to an int
ll = int(self.options.loglevel) if self.options.loglevel.isdigit() else self.options.loglevel.upper()
ch.setLevel(ll)
# Format logs the same as bitcoind's debug.log with microprecision (so log files can be concatenated and sorted)
# Format logs the same as lbrycrdd's debug.log with microprecision (so log files can be concatenated and sorted)
formatter = logging.Formatter(fmt='%(asctime)s.%(msecs)03d000Z %(name)s (%(levelname)s): %(message)s', datefmt='%Y-%m-%dT%H:%M:%S')
formatter.converter = time.gmtime
fh.setFormatter(formatter)
@ -506,7 +506,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
extra_args=['-disablewallet'],
rpchost=None,
timewait=self.rpc_timeout,
bitcoind=self.options.bitcoind,
lbrycrdd=self.options.bitcoind,
bitcoin_cli=self.options.bitcoincli,
coverage_dir=None,
cwd=self.options.tmpdir,
@ -546,7 +546,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.log.debug("Copy cache directory {} to node {}".format(cache_node_dir, i))
to_dir = get_datadir_path(self.options.tmpdir, i)
shutil.copytree(cache_node_dir, to_dir)
initialize_datadir(self.options.tmpdir, i, self.chain) # Overwrite port/rpcport in bitcoin.conf
initialize_datadir(self.options.tmpdir, i, self.chain) # Overwrite port/rpcport in lbrycrd.conf
def _initialize_chain_clean(self):
"""Initialize empty blockchain for use by the test.
@ -563,10 +563,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
except ImportError:
raise SkipTest("python3-zmq module not available.")
def skip_if_no_bitcoind_zmq(self):
"""Skip the running test if bitcoind has not been compiled with zmq support."""
def skip_if_no_lbrycrdd_zmq(self):
"""Skip the running test if lbrycrdd has not been compiled with zmq support."""
if not self.is_zmq_compiled():
raise SkipTest("bitcoind has not been built with zmq enabled.")
raise SkipTest("lbrycrdd has not been built with zmq enabled.")
def skip_if_no_wallet(self):
"""Skip the running test if wallet has not been compiled."""
@ -574,12 +574,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
raise SkipTest("wallet has not been compiled.")
def skip_if_no_cli(self):
"""Skip the running test if bitcoin-cli has not been compiled."""
"""Skip the running test if lbrycrd-cli has not been compiled."""
if not self.is_cli_compiled():
raise SkipTest("bitcoin-cli has not been compiled.")
raise SkipTest("lbrycrd-cli has not been compiled.")
def is_cli_compiled(self):
"""Checks whether bitcoin-cli was compiled."""
"""Checks whether lbrycrd-cli was compiled."""
return config["components"].getboolean("ENABLE_UTILS")

View file

@ -2,7 +2,7 @@
# Copyright (c) 2017-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Class for bitcoind node under test"""
"""Class for lbrycrdd node under test"""
import contextlib
import decimal
@ -32,7 +32,7 @@ from .util import (
p2p_port,
)
BITCOIND_PROC_WAIT_TIMEOUT = 60
LBRYCRDD_PROC_WAIT_TIMEOUT = 60
class FailedToStartError(Exception):
@ -46,7 +46,7 @@ class ErrorMatch(Enum):
class TestNode():
"""A class for representing a bitcoind node under test.
"""A class for representing a lbrycrdd node under test.
This class contains:
@ -59,7 +59,7 @@ class TestNode():
To make things easier for the test writer, any unrecognised messages will
be dispatched to the RPC connection."""
def __init__(self, i, datadir, *, chain, rpchost, timewait, bitcoind, bitcoin_cli, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False):
def __init__(self, i, datadir, *, chain, rpchost, timewait, lbrycrdd, bitcoin_cli, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False):
"""
Kwargs:
start_perf (bool): If True, begin profiling the node with `perf` as soon as
@ -74,7 +74,7 @@ class TestNode():
self.chain = chain
self.rpchost = rpchost
self.rpc_timeout = timewait
self.binary = bitcoind
self.binary = lbrycrdd
self.coverage_dir = coverage_dir
self.cwd = cwd
if extra_conf is not None:
@ -163,7 +163,7 @@ class TestNode():
raise AssertionError(self._node_msg(msg))
def __del__(self):
# Ensure that we don't leave any bitcoind processes lying around after
# Ensure that we don't leave any lbrycrdd processes lying around after
# the test ends
if self.process and self.cleanup_on_exit:
# Should only happen on test failure
@ -185,7 +185,7 @@ class TestNode():
if extra_args is None:
extra_args = self.extra_args
# Add a new stdout and stderr file each time bitcoind is started
# Add a new stdout and stderr file each time lbrycrdd is started
if stderr is None:
stderr = tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False)
if stdout is None:
@ -197,7 +197,7 @@ class TestNode():
cwd = self.cwd
# Delete any existing cookie file -- if such a file exists (eg due to
# unclean shutdown), it will get overwritten anyway by bitcoind, and
# unclean shutdown), it will get overwritten anyway by lbrycrdd, and
# potentially interfere with our attempt to authenticate
delete_cookie_file(self.datadir, self.chain)
@ -207,19 +207,19 @@ class TestNode():
self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, cwd=cwd, **kwargs)
self.running = True
self.log.debug("bitcoind started, waiting for RPC to come up")
self.log.debug("lbrycrdd started, waiting for RPC to come up")
if self.start_perf:
self._start_perf()
def wait_for_rpc_connection(self):
"""Sets up an RPC connection to the bitcoind process. Returns False if unable to connect."""
"""Sets up an RPC connection to the lbrycrdd process. Returns False if unable to connect."""
# Poll at a rate of four times per second
poll_per_s = 4
for _ in range(poll_per_s * self.rpc_timeout):
if self.process.poll() is not None:
raise FailedToStartError(self._node_msg(
'bitcoind exited with status {} during initialization'.format(self.process.returncode)))
'lbrycrdd exited with status {} during initialization'.format(self.process.returncode)))
try:
rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.chain, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
rpc.getblockcount()
@ -239,11 +239,11 @@ class TestNode():
# -342 Service unavailable, RPC server started but is shutting down due to error
if e.error['code'] != -28 and e.error['code'] != -342:
raise # unknown JSON RPC exception
except ValueError as e: # cookie file not found and no rpcuser or rpcassword. bitcoind still starting
except ValueError as e: # cookie file not found and no rpcuser or rpcassword. lbrycrdd still starting
if "No RPC credentials" not in str(e):
raise
time.sleep(1.0 / poll_per_s)
self._raise_assertion_error("Unable to connect to bitcoind")
self._raise_assertion_error("Unable to connect to lbrycrdd")
def generate(self, nblocks, maxtries=1000000):
self.log.debug("TestNode.generate() dispatches `generate` call to `generatetoaddress`")
@ -303,7 +303,7 @@ class TestNode():
self.log.debug("Node stopped")
return True
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
def wait_until_stopped(self, timeout=LBRYCRDD_PROC_WAIT_TIMEOUT):
wait_until(self.is_node_stopped, timeout=timeout)
@contextlib.contextmanager
@ -440,11 +440,11 @@ class TestNode():
def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, match=ErrorMatch.FULL_TEXT, *args, **kwargs):
"""Attempt to start the node and expect it to raise an error.
extra_args: extra arguments to pass through to bitcoind
expected_msg: regex that stderr should match when bitcoind fails
extra_args: extra arguments to pass through to lbrycrdd
expected_msg: regex that stderr should match when lbrycrdd fails
Will throw if bitcoind starts without an error.
Will throw if an expected_msg is provided and it does not match bitcoind's stdout."""
Will throw if lbrycrdd starts without an error.
Will throw if an expected_msg is provided and it does not match lbrycrdd's stdout."""
with tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False) as log_stderr, \
tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) as log_stdout:
try:
@ -453,7 +453,7 @@ class TestNode():
self.stop_node()
self.wait_until_stopped()
except FailedToStartError as e:
self.log.debug('bitcoind failed to start: %s', e)
self.log.debug('lbrycrdd failed to start: %s', e)
self.running = False
self.process = None
# Check stderr for expected message
@ -474,9 +474,9 @@ class TestNode():
'Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr))
else:
if expected_msg is None:
assert_msg = "bitcoind should have exited with an error"
assert_msg = "lbrycrdd should have exited with an error"
else:
assert_msg = "bitcoind should have exited with expected error " + expected_msg
assert_msg = "lbrycrdd should have exited with expected error " + expected_msg
self._raise_assertion_error(assert_msg)
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):

View file

@ -302,7 +302,7 @@ def initialize_datadir(dirname, n, chain):
else:
chain_name_conf_arg = chain
chain_name_conf_section = chain
with open(os.path.join(datadir, "bitcoin.conf"), 'w', encoding='utf8') as f:
with open(os.path.join(datadir, "lbrycrd.conf"), 'w', encoding='utf8') as f:
f.write("{}=1\n".format(chain_name_conf_arg))
f.write("[{}]\n".format(chain_name_conf_section))
f.write("port=" + str(p2p_port(n)) + "\n")
@ -322,15 +322,15 @@ def get_datadir_path(dirname, n):
return os.path.join(dirname, "node" + str(n))
def append_config(datadir, options):
with open(os.path.join(datadir, "bitcoin.conf"), 'a', encoding='utf8') as f:
with open(os.path.join(datadir, "lbrycrd.conf"), 'a', encoding='utf8') as f:
for option in options:
f.write(option + "\n")
def get_auth_cookie(datadir, chain):
user = None
password = None
if os.path.isfile(os.path.join(datadir, "bitcoin.conf")):
with open(os.path.join(datadir, "bitcoin.conf"), 'r', encoding='utf8') as f:
if os.path.isfile(os.path.join(datadir, "lbrycrd.conf")):
with open(os.path.join(datadir, "lbrycrd.conf"), 'r', encoding='utf8') as f:
for line in f:
if line.startswith("rpcuser="):
assert user is None # Ensure that there is only one rpcuser line

View file

@ -277,9 +277,9 @@ def main():
logging.debug("Temporary test directory at %s" % tmpdir)
enable_bitcoind = config["components"].getboolean("ENABLE_BITCOIND")
enable_lbrycrdd = config["components"].getboolean("ENABLE_LBRYCRDD")
if not enable_bitcoind:
if not enable_lbrycrdd:
print("No functional tests to run.")
print("Rerun ./configure with --with-daemon and then make")
sys.exit(0)
@ -361,11 +361,11 @@ def main():
def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, runs_ci, use_term_control):
args = args or []
# Warn if bitcoind is already running
# Warn if lbrycrdd is already running (unix only)
# pidof might fail or return an empty string if bitcoind is not running
try:
if subprocess.check_output(["pidof", "bitcoind"]) not in [b'']:
print("%sWARNING!%s There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!" % (BOLD[1], BOLD[0]))
if subprocess.check_output(["pidof", "lbrycrdd"]) not in [b'']:
print("%sWARNING!%s There is already a lbrycrdd process running on this system. Tests may fail unexpectedly due to resource contention!" % (BOLD[1], BOLD[0]))
except (OSError, subprocess.SubprocessError):
pass

View file

@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test multiwallet.
Verify that a bitcoind node can load multiple wallet files
Verify that a lbrycrdd node can load multiple wallet files
"""
import os
import shutil

View file

@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the zapwallettxes functionality.
- start two bitcoind nodes
- start two lbrycrdd nodes
- create two transactions on node 0 - one is confirmed and one is unconfirmed.
- restart node 0 and verify that both the confirmed and the unconfirmed
transactions are still available.

View file

@ -54,9 +54,11 @@ EXPECTED_BOOST_INCLUDES=(
boost/algorithm/string/replace.hpp
boost/algorithm/string/split.hpp
boost/chrono/chrono.hpp
boost/container/flat_map.hpp
boost/date_time/posix_time/posix_time.hpp
boost/filesystem.hpp
boost/filesystem/fstream.hpp
boost/locale.hpp
boost/multi_index/hashed_index.hpp
boost/multi_index/ordered_index.hpp
boost/multi_index/sequenced_index.hpp
@ -64,9 +66,13 @@ EXPECTED_BOOST_INCLUDES=(
boost/optional.hpp
boost/preprocessor/cat.hpp
boost/preprocessor/stringize.hpp
boost/scope_exit.hpp
boost/scoped_ptr.hpp
boost/signals2/connection.hpp
boost/signals2/last_value.hpp
boost/signals2/signal.hpp
boost/test/output_test_stream.hpp
boost/test/unit_test_parameters.hpp
boost/test/unit_test.hpp
boost/thread.hpp
boost/thread/condition_variable.hpp

31
test_cli.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -u -e -o pipefail
trap "kill 0" EXIT
"$(pwd)/test/util/bitcoin-util-test.py"
"$(pwd)/test/util/rpcauth-test.py"
"$(pwd)/test/lint/lint-filenames.sh"
"$(pwd)/test/lint/lint-include-guards.sh"
"$(pwd)/test/lint/lint-includes.sh"
"$(pwd)/test/lint/lint-tests.sh"
"$(pwd)/test/lint/lint-whitespace.sh"
# TODO: make the rest of these work:
#"$(pwd)/test/functional/test_runner.py" interface_rest
# do a little run-through of the basic CLI commands:
rm -fr /tmp/regtest_cli_testing
mkdir /tmp/regtest_cli_testing
CLI="$(pwd)/src/lbrycrd-cli -regtest -datadir=/tmp/regtest_cli_testing"
"$(pwd)/src/lbrycrdd" -regtest -txindex -datadir=/tmp/regtest_cli_testing -printtoconsole=0 &
sleep 3
while [[ "$($CLI help)" == *"Loading"* ]]; do sleep 1; done
GEN150=$($CLI generate 120)
TX=$($CLI claimname tester deadbeef 1)
GEN1=$($CLI generate 1)
LIST=$($CLI listnameclaims)
if [[ "$LIST" != *"$TX"* ]]; then exit 1; fi