in progress on making py tests run
This commit is contained in:
parent
96fdb05689
commit
92a3df1571
43 changed files with 179 additions and 169 deletions
|
@ -41,7 +41,6 @@ BITCOIN_TESTS =\
|
||||||
test/blockchain_tests.cpp \
|
test/blockchain_tests.cpp \
|
||||||
test/blockencodings_tests.cpp \
|
test/blockencodings_tests.cpp \
|
||||||
test/bloom_tests.cpp \
|
test/bloom_tests.cpp \
|
||||||
test/Checkpoints_tests.cpp \
|
|
||||||
test/bswap_tests.cpp \
|
test/bswap_tests.cpp \
|
||||||
test/checkqueue_tests.cpp \
|
test/checkqueue_tests.cpp \
|
||||||
test/coins_tests.cpp \
|
test/coins_tests.cpp \
|
||||||
|
|
|
@ -62,8 +62,7 @@ bool CClaimScriptUndoAddOp::supportClaim(CClaimTrieCache& trieCache, const std::
|
||||||
if (LogAcceptCategory(BCLog::CLAIMS)) {
|
if (LogAcceptCategory(BCLog::CLAIMS)) {
|
||||||
LogPrintf("--- [%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name,
|
LogPrintf("--- [%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name,
|
||||||
claimId.GetHex(), point.hash.ToString(), point.n);
|
claimId.GetHex(), point.hash.ToString(), point.n);
|
||||||
LogPrintf(
|
LogPrintf("%s: (txid: %s, nOut: %d) Removing support for %s, claimId: %s, from the claim trie due to block disconnect\n",
|
||||||
"%s: (txid: %s, nOut: %d) Removing support for %s, claimId: %s, from the claim trie due to block disconnect\n",
|
|
||||||
__func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
__func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||||
}
|
}
|
||||||
bool res = trieCache.undoAddSupport(name, point, nHeight);
|
bool res = trieCache.undoAddSupport(name, point, nHeight);
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#ifndef CLAIMSCRIPTOP_H
|
#ifndef BITCOIN_CLAIMSCRIPTOP_H
|
||||||
#define CLAIMSCRIPTOP_H
|
#define BITCOIN_CLAIMSCRIPTOP_H
|
||||||
|
|
||||||
#include "amount.h"
|
#include <amount.h>
|
||||||
#include "claimtrie.h"
|
#include <claimtrie.h>
|
||||||
#include "hash.h"
|
#include <hash.h>
|
||||||
#include "primitives/transaction.h"
|
#include <primitives/transaction.h>
|
||||||
#include "script/script.h"
|
#include <script/script.h>
|
||||||
#include "uint256.h"
|
#include <uint256.h>
|
||||||
#include "util.h"
|
#include <util.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -242,4 +242,4 @@ struct CUpdateCacheCallbacks
|
||||||
*/
|
*/
|
||||||
void UpdateCache(const CTransaction& tx, CClaimTrieCache& trieCache, const CCoinsViewCache& view, int nHeight, const CUpdateCacheCallbacks& callbacks = {});
|
void UpdateCache(const CTransaction& tx, CClaimTrieCache& trieCache, const CCoinsViewCache& view, int nHeight, const CUpdateCacheCallbacks& callbacks = {});
|
||||||
|
|
||||||
#endif // CLAIMSCRIPTOP_H
|
#endif // BITCOIN_CLAIMSCRIPTOP_H
|
||||||
|
|
|
@ -4,11 +4,7 @@
|
||||||
#include <claimtrie.h>
|
#include <claimtrie.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/locale.hpp>
|
#include <boost/locale.hpp>
|
||||||
#include <boost/locale/conversion.hpp>
|
|
||||||
#include <boost/locale/localization_backend.hpp>
|
|
||||||
#include <boost/scope_exit.hpp>
|
#include <boost/scope_exit.hpp>
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef LBRY_H
|
#ifndef BITCOIN_LBRY_H
|
||||||
#define LBRY_H
|
#define BITCOIN_LBRY_H
|
||||||
|
|
||||||
#include <chain.h>
|
#include <chain.h>
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "nameclaim.h"
|
#include <nameclaim.h>
|
||||||
#include "hash.h"
|
#include <hash.h>
|
||||||
#include "util.h"
|
#include <util.h>
|
||||||
|
|
||||||
std::vector<unsigned char> uint32_t_to_vch(uint32_t n)
|
std::vector<unsigned char> uint32_t_to_vch(uint32_t n)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef BITCOIN_NAMECLAIM_H
|
#ifndef BITCOIN_NAMECLAIM_H
|
||||||
#define BITCOIN_NAMECLAIM_H
|
#define BITCOIN_NAMECLAIM_H
|
||||||
|
|
||||||
#include "amount.h"
|
#include <amount.h>
|
||||||
#include "script/script.h"
|
#include <script/script.h>
|
||||||
#include "primitives/transaction.h"
|
#include <primitives/transaction.h>
|
||||||
#include "uint256.h"
|
#include <uint256.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
#include <prefixtrie.h>
|
||||||
#include "prefixtrie.h"
|
#include <claimtrie.h>
|
||||||
#include "claimtrie.h"
|
|
||||||
|
|
||||||
template <typename TKey, typename TData>
|
template <typename TKey, typename TData>
|
||||||
template <bool IsConst>
|
template <bool IsConst>
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <boost/locale.hpp>
|
#include <boost/locale.hpp>
|
||||||
#include <boost/locale/conversion.hpp>
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
|
@ -436,9 +436,17 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
|
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript scriptPubKey = GetScriptForDestination(destination);
|
auto rawAmount = outputs[name_];
|
||||||
CAmount nAmount = AmountFromValue(outputs[name_]);
|
CAmount nAmount;
|
||||||
|
CScript prefix;
|
||||||
|
if (rawAmount.isArray() && rawAmount.size() > 2) {
|
||||||
|
nAmount = AmountFromValue(rawAmount[0]);
|
||||||
|
prefix = ClaimNameScript(rawAmount[1].get_str(), rawAmount[2].get_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nAmount = AmountFromValue(outputs[name_]);
|
||||||
|
|
||||||
|
CScript scriptPubKey = prefix + GetScriptForDestination(destination);
|
||||||
CTxOut out(nAmount, scriptPubKey);
|
CTxOut out(nAmount, scriptPubKey);
|
||||||
rawTx.vout.push_back(out);
|
rawTx.vout.push_back(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
|
||||||
// Distributed under the MIT software license, see the accompanying
|
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
|
|
||||||
//
|
|
||||||
// Unit tests for block-chain checkpoints
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "checkpoints.h"
|
|
||||||
|
|
||||||
#include "uint256.h"
|
|
||||||
#include "test/test_bitcoin.h"
|
|
||||||
#include "chainparams.h"
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(sanity)
|
|
||||||
{
|
|
||||||
//const CCheckpointData& checkpoints = Params(CBaseChainParams::MAIN).Checkpoints();
|
|
||||||
//BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate(checkpoints) >= 134444);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <rpc/register.h>
|
#include <rpc/register.h>
|
||||||
#include <script/sigcache.h>
|
#include <script/sigcache.h>
|
||||||
|
|
||||||
#include "claimtrie.h"
|
#include <claimtrie.h>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/test/unit_test_parameters.hpp>
|
#include <boost/test/unit_test_parameters.hpp>
|
||||||
|
|
||||||
|
|
|
@ -15,5 +15,5 @@ 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.
|
# Which components are enabled. These are commented out by `configure` if they were disabled when running config.
|
||||||
@ENABLE_WALLET_TRUE@ENABLE_WALLET=true
|
@ENABLE_WALLET_TRUE@ENABLE_WALLET=true
|
||||||
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=true
|
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=true
|
||||||
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=true
|
@BUILD_BITCOIND_TRUE@ENABLE_LBRYCRDD=true
|
||||||
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
|
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
|
||||||
|
|
|
@ -309,7 +309,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||||
b26 = self.update_block(26, [])
|
b26 = self.update_block(26, [])
|
||||||
self.sync_blocks([b26], success=False, reject_code=16, reject_reason=b'bad-cb-length', reconnect=True)
|
self.sync_blocks([b26], success=False, reject_code=16, reject_reason=b'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])
|
b27 = self.next_block(27, spend=out[7])
|
||||||
self.sync_blocks([b27], False)
|
self.sync_blocks([b27], False)
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||||
b28 = self.update_block(28, [])
|
b28 = self.update_block(28, [])
|
||||||
self.sync_blocks([b28], success=False, reject_code=16, reject_reason=b'bad-cb-length', reconnect=True)
|
self.sync_blocks([b28], success=False, reject_code=16, reject_reason=b'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])
|
b29 = self.next_block(29, spend=out[7])
|
||||||
self.sync_blocks([b29], False)
|
self.sync_blocks([b29], False)
|
||||||
|
|
||||||
|
@ -829,7 +829,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||||
assert_equal(len(b64a.serialize()), MAX_BLOCK_BASE_SIZE + 8)
|
assert_equal(len(b64a.serialize()), MAX_BLOCK_BASE_SIZE + 8)
|
||||||
self.sync_blocks([b64a], success=False, reject_code=1, reject_reason=b'error parsing message')
|
self.sync_blocks([b64a], success=False, reject_code=1, reject_reason=b'error parsing message')
|
||||||
|
|
||||||
# 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
|
# resend the header message, it won't send us the getdata message again. Just
|
||||||
# disconnect and reconnect and then call sync_blocks.
|
# disconnect and reconnect and then call sync_blocks.
|
||||||
# TODO: improve this test to be less dependent on P2P DOS behaviour.
|
# TODO: improve this test to be less dependent on P2P DOS behaviour.
|
||||||
|
|
|
@ -21,7 +21,7 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||||
# Assume node is stopped
|
# Assume node is stopped
|
||||||
|
|
||||||
inc_conf_file_path = os.path.join(self.nodes[0].datadir, 'include.conf')
|
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))
|
conf.write('includeconf={}\n'.format(inc_conf_file_path))
|
||||||
|
|
||||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||||
|
@ -52,7 +52,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.')
|
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
|
# 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
|
# datadir needs to be set before [regtest] section
|
||||||
conf_file_contents = open(conf_file, encoding='utf8').read()
|
conf_file_contents = open(conf_file, encoding='utf8').read()
|
||||||
|
|
|
@ -87,14 +87,14 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||||
return utxo_hash
|
return utxo_hash
|
||||||
except:
|
except:
|
||||||
# An exception here should mean the node is about to crash.
|
# An exception here should mean the node is about to crash.
|
||||||
# If bitcoind exits, then try again. wait_for_node_exit()
|
# If lbrycrdd exits, then try again. wait_for_node_exit()
|
||||||
# should raise an exception if bitcoind doesn't exit.
|
# should raise an exception if lbrycrdd doesn't exit.
|
||||||
self.wait_for_node_exit(node_index, timeout=10)
|
self.wait_for_node_exit(node_index, timeout=10)
|
||||||
self.crashed_on_restart += 1
|
self.crashed_on_restart += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# If we got here, bitcoind isn't coming back up on restart. Could be a
|
# If we got here, lbrycrdd isn't coming back up on restart. Could be a
|
||||||
# bug in bitcoind, or we've gotten unlucky with our dbcrash ratio --
|
# bug in lbrycrdd, or we've gotten unlucky with our dbcrash ratio --
|
||||||
# perhaps we generated a test case that blew up our cache?
|
# perhaps we generated a test case that blew up our cache?
|
||||||
# TODO: If this happens a lot, we should try to restart without -dbcrashratio
|
# TODO: If this happens a lot, we should try to restart without -dbcrashratio
|
||||||
# and make sure that recovery happens.
|
# and make sure that recovery happens.
|
||||||
|
|
|
@ -118,9 +118,9 @@ class BIP66Test(BitcoinTestFramework):
|
||||||
wait_until(lambda: "reject" in self.nodes[0].p2p.last_message.keys(), lock=mininode_lock)
|
wait_until(lambda: "reject" in self.nodes[0].p2p.last_message.keys(), lock=mininode_lock)
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
# We can receive different reject messages depending on whether
|
# We can receive different reject messages depending on whether
|
||||||
# bitcoind is running with multiple script check threads. If script
|
# lbrycrdd is running with multiple script check threads. If script
|
||||||
# check threads are not in use, then transaction script validation
|
# check threads are not in use, then transaction script validation
|
||||||
# happens sequentially, and bitcoind produces more specific reject
|
# happens sequentially, and lbrycrdd produces more specific reject
|
||||||
# reasons.
|
# reasons.
|
||||||
assert self.nodes[0].p2p.last_message["reject"].code in [REJECT_INVALID, REJECT_NONSTANDARD]
|
assert self.nodes[0].p2p.last_message["reject"].code in [REJECT_INVALID, REJECT_NONSTANDARD]
|
||||||
assert_equal(self.nodes[0].p2p.last_message["reject"].data, block.sha256)
|
assert_equal(self.nodes[0].p2p.last_message["reject"].data, block.sha256)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class IncludeConfTest(BitcoinTestFramework):
|
||||||
# - tmpdir/node0/relative2.conf
|
# - tmpdir/node0/relative2.conf
|
||||||
with open(os.path.join(self.options.tmpdir, "node0", "relative2.conf"), "w", encoding="utf8") as f:
|
with open(os.path.join(self.options.tmpdir, "node0", "relative2.conf"), "w", encoding="utf8") as f:
|
||||||
f.write("uacomment=relative2\n")
|
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")
|
f.write("uacomment=main\nincludeconf=relative.conf\n")
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
@ -70,7 +70,7 @@ class IncludeConfTest(BitcoinTestFramework):
|
||||||
# Restore initial file contents
|
# Restore initial file contents
|
||||||
f.write("uacomment=relative\n")
|
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")
|
f.write("includeconf=relative2.conf\n")
|
||||||
|
|
||||||
self.start_node(0)
|
self.start_node(0)
|
||||||
|
|
|
@ -69,7 +69,7 @@ class NotificationsTest(BitcoinTestFramework):
|
||||||
self.nodes[1].generate(41)
|
self.nodes[1].generate(41)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
# Give bitcoind 10 seconds to write the alert notification
|
# Give lbrycrdd 10 seconds to write the alert notification
|
||||||
wait_until(lambda: os.path.isfile(self.alert_filename) and os.path.getsize(self.alert_filename), timeout=10)
|
wait_until(lambda: os.path.isfile(self.alert_filename) and os.path.getsize(self.alert_filename), timeout=10)
|
||||||
|
|
||||||
with open(self.alert_filename, 'r', encoding='utf8') as f:
|
with open(self.alert_filename, 'r', encoding='utf8') as f:
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
# Copyright (c) 2015-2018 The Bitcoin Core developers
|
# Copyright (c) 2015-2018 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# 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:
|
Test plan:
|
||||||
- Start bitcoind's with different proxy configurations
|
- Start lbrycrdd's with different proxy configurations
|
||||||
- Use addnode to initiate connections
|
- Use addnode to initiate connections
|
||||||
- Verify that proxies are connected to, and the right connection command is given
|
- 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)
|
- `-proxy` (proxy everything)
|
||||||
- `-onion` (proxy just onions)
|
- `-onion` (proxy just onions)
|
||||||
- `-proxyrandomize` Circuit randomization
|
- `-proxyrandomize` Circuit randomization
|
||||||
|
@ -18,8 +18,8 @@ Test plan:
|
||||||
- proxy on IPv6
|
- proxy on IPv6
|
||||||
|
|
||||||
- Create various proxies (as threads)
|
- Create various proxies (as threads)
|
||||||
- Create bitcoinds that connect to them
|
- Create lbrycrdds that connect to them
|
||||||
- Manipulate the bitcoinds using addnode (onetry) an observe effects
|
- Manipulate the lbrycrdds using addnode (onetry) an observe effects
|
||||||
|
|
||||||
addnode connect to IPv4
|
addnode connect to IPv4
|
||||||
addnode connect to IPv6
|
addnode connect to IPv6
|
||||||
|
@ -95,7 +95,7 @@ class ProxyTest(BitcoinTestFramework):
|
||||||
node.addnode("15.61.23.23:1234", "onetry")
|
node.addnode("15.61.23.23:1234", "onetry")
|
||||||
cmd = proxies[0].queue.get()
|
cmd = proxies[0].queue.get()
|
||||||
assert(isinstance(cmd, Socks5Command))
|
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.atyp, AddressType.DOMAINNAME)
|
||||||
assert_equal(cmd.addr, b"15.61.23.23")
|
assert_equal(cmd.addr, b"15.61.23.23")
|
||||||
assert_equal(cmd.port, 1234)
|
assert_equal(cmd.port, 1234)
|
||||||
|
@ -109,7 +109,7 @@ class ProxyTest(BitcoinTestFramework):
|
||||||
node.addnode("[1233:3432:2434:2343:3234:2345:6546:4534]:5443", "onetry")
|
node.addnode("[1233:3432:2434:2343:3234:2345:6546:4534]:5443", "onetry")
|
||||||
cmd = proxies[1].queue.get()
|
cmd = proxies[1].queue.get()
|
||||||
assert(isinstance(cmd, Socks5Command))
|
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.atyp, AddressType.DOMAINNAME)
|
||||||
assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534")
|
assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534")
|
||||||
assert_equal(cmd.port, 5443)
|
assert_equal(cmd.port, 5443)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright (c) 2014-2018 The Bitcoin Core developers
|
# Copyright (c) 2014-2018 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# 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.
|
- 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.
|
- Stop the node and restart it with -reindex. Verify that the node has reindexed up to block 3.
|
||||||
|
|
|
@ -94,7 +94,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||||
# is cleared. This will move the versionbit state to ACTIVE.
|
# is cleared. This will move the versionbit state to ACTIVE.
|
||||||
node.generate(VB_PERIOD)
|
node.generate(VB_PERIOD)
|
||||||
|
|
||||||
# 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)
|
self.restart_node(0)
|
||||||
|
|
||||||
# Generating one block guarantees that we'll get out of IBD
|
# Generating one block guarantees that we'll get out of IBD
|
||||||
|
|
|
@ -88,7 +88,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert(b'"error":null' in out1)
|
assert(b'"error":null' in out1)
|
||||||
assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default
|
assert(conn.sock!=None) #connection must be closed because lbrycrdd should use keep-alive by default
|
||||||
|
|
||||||
# Check excessive request size
|
# Check excessive request size
|
||||||
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
||||||
|
|
|
@ -40,7 +40,7 @@ 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_lbrycrdd_zmq()
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
||||||
def setup_nodes(self):
|
def setup_nodes(self):
|
||||||
|
@ -57,7 +57,7 @@ class ZMQTest (BitcoinTestFramework):
|
||||||
# that this test fails if the publishing order changes.
|
# that this test fails if the publishing order changes.
|
||||||
# Note that the publishing order is not defined in the documentation and
|
# Note that the publishing order is not defined in the documentation and
|
||||||
# is subject to change.
|
# is subject to change.
|
||||||
address = "tcp://127.0.0.1:28332"
|
address = "tcp://127.0.0.1:29245"
|
||||||
self.zmq_context = zmq.Context()
|
self.zmq_context = zmq.Context()
|
||||||
socket = self.zmq_context.socket(zmq.SUB)
|
socket = self.zmq_context.socket(zmq.SUB)
|
||||||
socket.set(zmq.RCVTIMEO, 60000)
|
socket.set(zmq.RCVTIMEO, 60000)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test mempool persistence.
|
"""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
|
then reload it on startup. This can be overridden with
|
||||||
the -persistmempool=0 command line option.
|
the -persistmempool=0 command line option.
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class MempoolPersistTest(BitcoinTestFramework):
|
||||||
self.start_node(1, extra_args=["-persistmempool=0"])
|
self.start_node(1, extra_args=["-persistmempool=0"])
|
||||||
self.start_node(0)
|
self.start_node(0)
|
||||||
self.start_node(2)
|
self.start_node(2)
|
||||||
# Give bitcoind a second to reload the mempool
|
# Give lbrycrdd a second to reload the mempool
|
||||||
wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5, timeout=1)
|
wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5, timeout=1)
|
||||||
wait_until(lambda: len(self.nodes[2].getrawmempool()) == 5, timeout=1)
|
wait_until(lambda: len(self.nodes[2].getrawmempool()) == 5, timeout=1)
|
||||||
# The others have loaded their mempool. If node_1 loaded anything, we'd probably notice by now:
|
# The others have loaded their mempool. If node_1 loaded anything, we'd probably notice by now:
|
||||||
|
@ -88,7 +88,7 @@ class MempoolPersistTest(BitcoinTestFramework):
|
||||||
self.log.debug("Stop-start node0 with -persistmempool=0. Verify that it doesn't load its mempool.dat file.")
|
self.log.debug("Stop-start node0 with -persistmempool=0. Verify that it doesn't load its mempool.dat file.")
|
||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
self.start_node(0, extra_args=["-persistmempool=0"])
|
self.start_node(0, extra_args=["-persistmempool=0"])
|
||||||
# Give bitcoind a second to reload the mempool
|
# Give lbrycrdd a second to reload the mempool
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class MempoolPersistTest(BitcoinTestFramework):
|
||||||
self.start_node(1, extra_args=[])
|
self.start_node(1, extra_args=[])
|
||||||
wait_until(lambda: len(self.nodes[1].getrawmempool()) == 5)
|
wait_until(lambda: 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
|
# 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
|
# which is an implementation detail that could change and break this test
|
||||||
mempooldotnew1 = mempooldat1 + '.new'
|
mempooldotnew1 = mempooldat1 + '.new'
|
||||||
|
|
|
@ -18,7 +18,7 @@ from test_framework.script import CScript, OP_TRUE, OP_DROP
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import assert_equal, get_bip9_status, satoshi_round, sync_blocks, wait_until
|
from test_framework.util import assert_equal, get_bip9_status, satoshi_round, sync_blocks, wait_until
|
||||||
|
|
||||||
# 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):
|
class TestP2PConn(P2PInterface):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -241,7 +241,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
old_node.request_headers_and_sync(locator=[tip])
|
old_node.request_headers_and_sync(locator=[tip])
|
||||||
check_announcement_of_new_block(node, old_node, lambda p: "cmpctblock" in p.last_message)
|
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):
|
def test_invalid_cmpctblock_message(self):
|
||||||
self.nodes[0].generate(101)
|
self.nodes[0].generate(101)
|
||||||
block = self.build_block_on_tip(self.nodes[0])
|
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)
|
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.hashPrevBlock)
|
||||||
|
|
||||||
# Compare the generated shortids to what we expect based on BIP 152, given
|
# 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, node, test_node, version, use_witness_address):
|
def test_compactblock_construction(self, node, test_node, version, use_witness_address):
|
||||||
# Generate a bunch of transactions.
|
# Generate a bunch of transactions.
|
||||||
node.generate(101)
|
node.generate(101)
|
||||||
|
@ -370,7 +370,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
header_and_shortids.shortids.pop(0)
|
header_and_shortids.shortids.pop(0)
|
||||||
index += 1
|
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
|
# via header or inv, and that responding to getblocktxn causes the block
|
||||||
# to be successfully reconstructed.
|
# to be successfully reconstructed.
|
||||||
# Post-segwit: upgraded nodes would only make this request of cb-version-2,
|
# Post-segwit: upgraded nodes would only make this request of cb-version-2,
|
||||||
|
@ -552,7 +552,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
assert_equal(absolute_indexes, [6, 7, 8, 9, 10])
|
assert_equal(absolute_indexes, [6, 7, 8, 9, 10])
|
||||||
|
|
||||||
# Now give an incorrect response.
|
# 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
|
# lying, since it could check to see if the shortid matches what we're
|
||||||
# sending, and eg disconnect us for misbehavior. If that behavior
|
# sending, and eg disconnect us for misbehavior. If that behavior
|
||||||
# change was made, we could just modify this test by having a
|
# change was made, we could just modify this test by having a
|
||||||
|
@ -582,7 +582,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
assert_equal(int(node.getbestblockhash(), 16), block.sha256)
|
assert_equal(int(node.getbestblockhash(), 16), block.sha256)
|
||||||
|
|
||||||
def test_getblocktxn_handler(self, node, test_node, version):
|
def test_getblocktxn_handler(self, node, test_node, version):
|
||||||
# bitcoind will not send blocktxn responses for blocks whose height is
|
# lbrycrdd will not send blocktxn responses for blocks whose height is
|
||||||
# more than 10 blocks deep.
|
# more than 10 blocks deep.
|
||||||
MAX_GETBLOCKTXN_DEPTH = 10
|
MAX_GETBLOCKTXN_DEPTH = 10
|
||||||
chain_height = node.getblockcount()
|
chain_height = node.getblockcount()
|
||||||
|
|
|
@ -58,7 +58,7 @@ class CLazyNode(P2PInterface):
|
||||||
# anyway, and eventually get disconnected.
|
# anyway, and eventually get disconnected.
|
||||||
class CNodeNoVersionBan(CLazyNode):
|
class CNodeNoVersionBan(CLazyNode):
|
||||||
# send a bunch of veracks without sending a message. This should get us disconnected.
|
# 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):
|
def on_open(self):
|
||||||
super().on_open()
|
super().on_open()
|
||||||
for i in range(banscore):
|
for i in range(banscore):
|
||||||
|
|
|
@ -778,7 +778,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
# This transaction should not be accepted into the mempool pre- or
|
# This transaction should not be accepted into the mempool pre- or
|
||||||
# post-segwit. Mempool acceptance will use SCRIPT_VERIFY_WITNESS which
|
# post-segwit. Mempool acceptance will use SCRIPT_VERIFY_WITNESS which
|
||||||
# will require a witness to spend a witness program regardless of
|
# 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.
|
# segwit-aware would also reject this for failing CLEANSTACK.
|
||||||
test_transaction_acceptance(self.nodes[0], self.test_node, spend_tx, with_witness=False, accepted=False)
|
test_transaction_acceptance(self.nodes[0], self.test_node, spend_tx, with_witness=False, accepted=False)
|
||||||
|
|
||||||
|
@ -1030,7 +1030,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
self.nodes[0].submitblock(bytes_to_hex_str(block.serialize(True)))
|
self.nodes[0].submitblock(bytes_to_hex_str(block.serialize(True)))
|
||||||
assert(self.nodes[0].getbestblockhash() != block.hash)
|
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)
|
add_witness_commitment(block, nonce=0)
|
||||||
block.vtx[0].wit = CTxWitness()
|
block.vtx[0].wit = CTxWitness()
|
||||||
block.solve()
|
block.solve()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test various net timeouts.
|
"""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_verack_node - we never send a verack in response to their version
|
||||||
no_version_node - we never send a version (only a ping)
|
no_version_node - we never send a version (only a ping)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright (c) 2014-2018 The Bitcoin Core developers
|
# Copyright (c) 2014-2018 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# 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
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class HTTPBasicsTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def setup_chain(self):
|
def setup_chain(self):
|
||||||
super().setup_chain()
|
super().setup_chain()
|
||||||
#Append rpcauth to bitcoin.conf before initialization
|
#Append rpcauth to lbrycrd.conf before initialization
|
||||||
rpcauth = "rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144"
|
rpcauth = "rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144"
|
||||||
rpcauth2 = "rpcauth=rt2:f8607b1a88861fac29dfccf9b52ff9f$ff36a0c23c8c62b4846112e50fa888416e94c17bfd4c42f88fd8f55ec6a3137e"
|
rpcauth2 = "rpcauth=rt2:f8607b1a88861fac29dfccf9b52ff9f$ff36a0c23c8c62b4846112e50fa888416e94c17bfd4c42f88fd8f55ec6a3137e"
|
||||||
rpcuser = "rpcuser=rpcuser💻"
|
rpcuser = "rpcuser=rpcuser💻"
|
||||||
|
@ -42,11 +42,11 @@ class HTTPBasicsTest(BitcoinTestFramework):
|
||||||
rpcauth3 = lines[1]
|
rpcauth3 = lines[1]
|
||||||
self.password = lines[3]
|
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(rpcauth+"\n")
|
||||||
f.write(rpcauth2+"\n")
|
f.write(rpcauth2+"\n")
|
||||||
f.write(rpcauth3+"\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")
|
f.write(rpcuser+"\n")
|
||||||
f.write(rpcpassword+"\n")
|
f.write(rpcpassword+"\n")
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from test_framework.util import assert_equal
|
||||||
|
|
||||||
class RPCZMQTest(BitcoinTestFramework):
|
class RPCZMQTest(BitcoinTestFramework):
|
||||||
|
|
||||||
address = "tcp://127.0.0.1:28332"
|
address = "tcp://127.0.0.1:29245"
|
||||||
|
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
|
@ -18,7 +18,7 @@ class RPCZMQTest(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_lbrycrdd_zmq()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self._test_getzmqnotifications()
|
self._test_getzmqnotifications()
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this software; if not, write to the Free Software
|
# along with this software; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# 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
|
AuthServiceProxy has the following improvements over python-jsonrpc's
|
||||||
ServiceProxy class:
|
ServiceProxy class:
|
||||||
|
|
|
@ -183,7 +183,7 @@ def FromHex(obj, hex_string):
|
||||||
def ToHex(obj):
|
def ToHex(obj):
|
||||||
return bytes_to_hex_str(obj.serialize())
|
return bytes_to_hex_str(obj.serialize())
|
||||||
|
|
||||||
# Objects that map to bitcoind objects, which can be serialized/deserialized
|
# Objects that map to lbrycrdd objects, which can be serialized/deserialized
|
||||||
|
|
||||||
class CAddress():
|
class CAddress():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -418,7 +418,7 @@ class CTransaction():
|
||||||
if len(self.vin) == 0:
|
if len(self.vin) == 0:
|
||||||
flags = struct.unpack("<B", f.read(1))[0]
|
flags = struct.unpack("<B", f.read(1))[0]
|
||||||
# Not sure why flags can't be zero, but this
|
# Not sure why flags can't be zero, but this
|
||||||
# matches the implementation in bitcoind
|
# matches the implementation in lbrycrdd
|
||||||
if (flags != 0):
|
if (flags != 0):
|
||||||
self.vin = deser_vector(f, CTxIn)
|
self.vin = deser_vector(f, CTxIn)
|
||||||
self.vout = deser_vector(f, CTxOut)
|
self.vout = deser_vector(f, CTxOut)
|
||||||
|
@ -1223,7 +1223,7 @@ class msg_headers():
|
||||||
self.headers = headers if headers is not None else []
|
self.headers = headers if headers is not None else []
|
||||||
|
|
||||||
def deserialize(self, f):
|
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)
|
blocks = deser_vector(f, CBlock)
|
||||||
for x in blocks:
|
for x in blocks:
|
||||||
self.headers.append(CBlockHeader(x))
|
self.headers.append(CBlockHeader(x))
|
||||||
|
|
|
@ -105,9 +105,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
|
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
|
||||||
parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true",
|
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",
|
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"),
|
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)")
|
help="Directory for caching pregenerated datadirs (default: %(default)s)")
|
||||||
parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
|
parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
|
||||||
|
@ -125,7 +125,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
|
parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
|
||||||
help="Attach a python debugger if test fails")
|
help="Attach a python debugger if test fails")
|
||||||
parser.add_argument("--usecli", dest="usecli", default=False, action="store_true",
|
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")
|
||||||
self.add_options(parser)
|
self.add_options(parser)
|
||||||
self.options = parser.parse_args()
|
self.options = parser.parse_args()
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read_file(open(self.options.configfile))
|
config.read_file(open(self.options.configfile))
|
||||||
self.options.bitcoind = os.getenv("BITCOIND", default=config["environment"]["BUILDDIR"] + '/src/bitcoind' + config["environment"]["EXEEXT"])
|
self.options.lbrycrdd = os.getenv("LBRYCRDD", default=config["environment"]["BUILDDIR"] + '/src/lbrycrdd' + config["environment"]["EXEEXT"])
|
||||||
self.options.bitcoincli = os.getenv("BITCOINCLI", default=config["environment"]["BUILDDIR"] + '/src/bitcoin-cli' + 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.environ['PATH'] = os.pathsep.join([
|
||||||
os.path.join(config['environment']['BUILDDIR'], 'src'),
|
os.path.join(config['environment']['BUILDDIR'], 'src'),
|
||||||
|
@ -196,7 +196,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
else:
|
else:
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
node.cleanup_on_exit = False
|
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")
|
||||||
|
|
||||||
if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED:
|
if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED:
|
||||||
self.log.info("Cleaning up {} on exit".format(self.options.tmpdir))
|
self.log.info("Cleaning up {} on exit".format(self.options.tmpdir))
|
||||||
|
@ -288,15 +288,15 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
if extra_args is None:
|
if extra_args is None:
|
||||||
extra_args = [[]] * num_nodes
|
extra_args = [[]] * num_nodes
|
||||||
if binary is None:
|
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_confs), num_nodes)
|
||||||
assert_equal(len(extra_args), num_nodes)
|
assert_equal(len(extra_args), num_nodes)
|
||||||
assert_equal(len(binary), num_nodes)
|
assert_equal(len(binary), num_nodes)
|
||||||
for i in range(num_nodes):
|
for i in range(num_nodes):
|
||||||
self.nodes.append(TestNode(i, get_datadir_path(self.options.tmpdir, i), rpchost=rpchost, timewait=self.rpc_timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
|
self.nodes.append(TestNode(i, get_datadir_path(self.options.tmpdir, i), rpchost=rpchost, timewait=self.rpc_timewait, lbrycrdd=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
|
||||||
|
|
||||||
def start_node(self, i, *args, **kwargs):
|
def start_node(self, i, *args, **kwargs):
|
||||||
"""Start a bitcoind"""
|
"""Start a lbrycrdd"""
|
||||||
|
|
||||||
node = self.nodes[i]
|
node = self.nodes[i]
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
||||||
|
|
||||||
def start_nodes(self, extra_args=None, *args, **kwargs):
|
def start_nodes(self, extra_args=None, *args, **kwargs):
|
||||||
"""Start multiple bitcoinds"""
|
"""Start multiple lbrycrdds"""
|
||||||
|
|
||||||
if extra_args is None:
|
if extra_args is None:
|
||||||
extra_args = [None] * self.num_nodes
|
extra_args = [None] * self.num_nodes
|
||||||
|
@ -327,12 +327,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
||||||
|
|
||||||
def stop_node(self, i, expected_stderr=''):
|
def stop_node(self, i, expected_stderr=''):
|
||||||
"""Stop a bitcoind test node"""
|
"""Stop a lbrycrdd test node"""
|
||||||
self.nodes[i].stop_node(expected_stderr)
|
self.nodes[i].stop_node(expected_stderr)
|
||||||
self.nodes[i].wait_until_stopped()
|
self.nodes[i].wait_until_stopped()
|
||||||
|
|
||||||
def stop_nodes(self):
|
def stop_nodes(self):
|
||||||
"""Stop multiple bitcoind test nodes"""
|
"""Stop multiple lbrycrdd test nodes"""
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
# Issue RPC to stop nodes
|
# Issue RPC to stop nodes
|
||||||
node.stop_node()
|
node.stop_node()
|
||||||
|
@ -382,7 +382,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
For backward compatibility of the python scripts with previous
|
For backward compatibility of the python scripts with previous
|
||||||
versions of the cache, this helper function sets mocktime to Jan 1,
|
versions of the cache, this helper function sets mocktime to Jan 1,
|
||||||
2014 + (201 * 10 * 60)"""
|
2014 + (201 * 10 * 60)"""
|
||||||
self.mocktime = 1388534400 + (201 * 10 * 60)
|
self.mocktime = 1388534400 + (201 * 10 * 60) + 86400 * 365 * 7
|
||||||
|
|
||||||
def disable_mocktime(self):
|
def disable_mocktime(self):
|
||||||
self.mocktime = 0
|
self.mocktime = 0
|
||||||
|
@ -401,7 +401,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
|
# 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()
|
ll = int(self.options.loglevel) if self.options.loglevel.isdigit() else self.options.loglevel.upper()
|
||||||
ch.setLevel(ll)
|
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 = logging.Formatter(fmt='%(asctime)s.%(msecs)03d000Z %(name)s (%(levelname)s): %(message)s', datefmt='%Y-%m-%dT%H:%M:%S')
|
||||||
formatter.converter = time.gmtime
|
formatter.converter = time.gmtime
|
||||||
fh.setFormatter(formatter)
|
fh.setFormatter(formatter)
|
||||||
|
@ -438,13 +438,13 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
if os.path.isdir(get_datadir_path(self.options.cachedir, i)):
|
if os.path.isdir(get_datadir_path(self.options.cachedir, i)):
|
||||||
shutil.rmtree(get_datadir_path(self.options.cachedir, i))
|
shutil.rmtree(get_datadir_path(self.options.cachedir, i))
|
||||||
|
|
||||||
# Create cache directories, run bitcoinds:
|
# Create cache directories, run lbrycrdds:
|
||||||
for i in range(MAX_NODES):
|
for i in range(MAX_NODES):
|
||||||
datadir = initialize_datadir(self.options.cachedir, i)
|
datadir = initialize_datadir(self.options.cachedir, i)
|
||||||
args = [self.options.bitcoind, "-datadir=" + datadir, '-disablewallet']
|
args = [self.options.lbrycrdd, "-datadir=" + datadir, '-disablewallet']
|
||||||
if i > 0:
|
if i > 0:
|
||||||
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
||||||
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
|
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, lbrycrdd=self.options.lbrycrdd, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
|
||||||
self.nodes[i].args = args
|
self.nodes[i].args = args
|
||||||
self.start_node(i)
|
self.start_node(i)
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
# Note: To preserve compatibility with older versions of
|
# Note: To preserve compatibility with older versions of
|
||||||
# initialize_chain, only 4 nodes will generate coins.
|
# initialize_chain, only 4 nodes will generate coins.
|
||||||
#
|
#
|
||||||
# blocks are created with timestamps 10 minutes apart
|
# blocks are created with timestamps 2 minutes apart
|
||||||
# starting from 2010 minutes in the past
|
# starting from 2010 minutes in the past
|
||||||
self.enable_mocktime()
|
self.enable_mocktime()
|
||||||
block_time = self.mocktime - (201 * 10 * 60)
|
block_time = self.mocktime - (201 * 10 * 60)
|
||||||
|
@ -488,7 +488,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
from_dir = get_datadir_path(self.options.cachedir, i)
|
from_dir = get_datadir_path(self.options.cachedir, i)
|
||||||
to_dir = get_datadir_path(self.options.tmpdir, i)
|
to_dir = get_datadir_path(self.options.tmpdir, i)
|
||||||
shutil.copytree(from_dir, to_dir)
|
shutil.copytree(from_dir, to_dir)
|
||||||
initialize_datadir(self.options.tmpdir, i) # Overwrite port/rpcport in bitcoin.conf
|
initialize_datadir(self.options.tmpdir, i) # Overwrite port/rpcport in lbrycrd.conf
|
||||||
|
|
||||||
def _initialize_chain_clean(self):
|
def _initialize_chain_clean(self):
|
||||||
"""Initialize empty blockchain for use by the test.
|
"""Initialize empty blockchain for use by the test.
|
||||||
|
@ -505,10 +505,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SkipTest("python3-zmq module not available.")
|
raise SkipTest("python3-zmq module not available.")
|
||||||
|
|
||||||
def skip_if_no_bitcoind_zmq(self):
|
def skip_if_no_lbrycrdd_zmq(self):
|
||||||
"""Skip the running test if bitcoind has not been compiled with zmq support."""
|
"""Skip the running test if lbrycrdd has not been compiled with zmq support."""
|
||||||
if not self.is_zmq_compiled():
|
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):
|
def skip_if_no_wallet(self):
|
||||||
"""Skip the running test if wallet has not been compiled."""
|
"""Skip the running test if wallet has not been compiled."""
|
||||||
|
@ -516,12 +516,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
raise SkipTest("wallet has not been compiled.")
|
raise SkipTest("wallet has not been compiled.")
|
||||||
|
|
||||||
def skip_if_no_cli(self):
|
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():
|
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):
|
def is_cli_compiled(self):
|
||||||
"""Checks whether bitcoin-cli was compiled."""
|
"""Checks whether lbrycrd-cli was compiled."""
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read_file(open(self.options.configfile))
|
config.read_file(open(self.options.configfile))
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright (c) 2017-2018 The Bitcoin Core developers
|
# Copyright (c) 2017-2018 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# 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 contextlib
|
||||||
import decimal
|
import decimal
|
||||||
|
@ -31,7 +31,7 @@ from .util import (
|
||||||
# For Python 3.4 compatibility
|
# For Python 3.4 compatibility
|
||||||
JSONDecodeError = getattr(json, "JSONDecodeError", ValueError)
|
JSONDecodeError = getattr(json, "JSONDecodeError", ValueError)
|
||||||
|
|
||||||
BITCOIND_PROC_WAIT_TIMEOUT = 60
|
LBRYCRDD_PROC_WAIT_TIMEOUT = 60
|
||||||
|
|
||||||
|
|
||||||
class FailedToStartError(Exception):
|
class FailedToStartError(Exception):
|
||||||
|
@ -45,7 +45,7 @@ class ErrorMatch(Enum):
|
||||||
|
|
||||||
|
|
||||||
class TestNode():
|
class TestNode():
|
||||||
"""A class for representing a bitcoind node under test.
|
"""A class for representing a lbrycrdd node under test.
|
||||||
|
|
||||||
This class contains:
|
This class contains:
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ class TestNode():
|
||||||
To make things easier for the test writer, any unrecognised messages will
|
To make things easier for the test writer, any unrecognised messages will
|
||||||
be dispatched to the RPC connection."""
|
be dispatched to the RPC connection."""
|
||||||
|
|
||||||
def __init__(self, i, datadir, *, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
|
def __init__(self, i, datadir, *, rpchost, timewait, lbrycrdd, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
|
||||||
self.index = i
|
self.index = i
|
||||||
self.datadir = datadir
|
self.datadir = datadir
|
||||||
self.stdout_dir = os.path.join(self.datadir, "stdout")
|
self.stdout_dir = os.path.join(self.datadir, "stdout")
|
||||||
self.stderr_dir = os.path.join(self.datadir, "stderr")
|
self.stderr_dir = os.path.join(self.datadir, "stderr")
|
||||||
self.rpchost = rpchost
|
self.rpchost = rpchost
|
||||||
self.rpc_timeout = timewait
|
self.rpc_timeout = timewait
|
||||||
self.binary = bitcoind
|
self.binary = lbrycrdd
|
||||||
self.coverage_dir = coverage_dir
|
self.coverage_dir = coverage_dir
|
||||||
if extra_conf != None:
|
if extra_conf != None:
|
||||||
append_config(datadir, extra_conf)
|
append_config(datadir, extra_conf)
|
||||||
|
@ -122,7 +122,7 @@ class TestNode():
|
||||||
raise AssertionError(self._node_msg(msg))
|
raise AssertionError(self._node_msg(msg))
|
||||||
|
|
||||||
def __del__(self):
|
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
|
# the test ends
|
||||||
if self.process and self.cleanup_on_exit:
|
if self.process and self.cleanup_on_exit:
|
||||||
# Should only happen on test failure
|
# Should only happen on test failure
|
||||||
|
@ -144,7 +144,7 @@ class TestNode():
|
||||||
if extra_args is None:
|
if extra_args is None:
|
||||||
extra_args = self.extra_args
|
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:
|
if stderr is None:
|
||||||
stderr = tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False)
|
stderr = tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False)
|
||||||
if stdout is None:
|
if stdout is None:
|
||||||
|
@ -153,7 +153,7 @@ class TestNode():
|
||||||
self.stdout = stdout
|
self.stdout = stdout
|
||||||
|
|
||||||
# Delete any existing cookie file -- if such a file exists (eg due to
|
# 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
|
# potentially interfere with our attempt to authenticate
|
||||||
delete_cookie_file(self.datadir)
|
delete_cookie_file(self.datadir)
|
||||||
|
|
||||||
|
@ -163,16 +163,16 @@ class TestNode():
|
||||||
self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, **kwargs)
|
self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, **kwargs)
|
||||||
|
|
||||||
self.running = True
|
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")
|
||||||
|
|
||||||
def wait_for_rpc_connection(self):
|
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 at a rate of four times per second
|
||||||
poll_per_s = 4
|
poll_per_s = 4
|
||||||
for _ in range(poll_per_s * self.rpc_timeout):
|
for _ in range(poll_per_s * self.rpc_timeout):
|
||||||
if self.process.poll() is not None:
|
if self.process.poll() is not None:
|
||||||
raise FailedToStartError(self._node_msg(
|
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:
|
try:
|
||||||
self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
|
self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
|
||||||
self.rpc.getblockcount()
|
self.rpc.getblockcount()
|
||||||
|
@ -187,11 +187,11 @@ class TestNode():
|
||||||
except JSONRPCException as e: # Initialization phase
|
except JSONRPCException as e: # Initialization phase
|
||||||
if e.error['code'] != -28: # RPC in warmup?
|
if e.error['code'] != -28: # RPC in warmup?
|
||||||
raise # unknown JSON RPC exception
|
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):
|
if "No RPC credentials" not in str(e):
|
||||||
raise
|
raise
|
||||||
time.sleep(1.0 / poll_per_s)
|
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 get_wallet_rpc(self, wallet_name):
|
def get_wallet_rpc(self, wallet_name):
|
||||||
if self.use_cli:
|
if self.use_cli:
|
||||||
|
@ -243,7 +243,7 @@ class TestNode():
|
||||||
self.log.debug("Node stopped")
|
self.log.debug("Node stopped")
|
||||||
return True
|
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)
|
wait_until(self.is_node_stopped, timeout=timeout)
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
@ -266,11 +266,11 @@ class TestNode():
|
||||||
def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, match=ErrorMatch.FULL_TEXT, *args, **kwargs):
|
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.
|
"""Attempt to start the node and expect it to raise an error.
|
||||||
|
|
||||||
extra_args: extra arguments to pass through to bitcoind
|
extra_args: extra arguments to pass through to lbrycrdd
|
||||||
expected_msg: regex that stderr should match when bitcoind fails
|
expected_msg: regex that stderr should match when lbrycrdd fails
|
||||||
|
|
||||||
Will throw if bitcoind starts without an error.
|
Will throw if lbrycrdd starts without an error.
|
||||||
Will throw if an expected_msg is provided and it does not match bitcoind's stdout."""
|
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, \
|
with tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False) as log_stderr, \
|
||||||
tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) as log_stdout:
|
tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) as log_stdout:
|
||||||
try:
|
try:
|
||||||
|
@ -279,7 +279,7 @@ class TestNode():
|
||||||
self.stop_node()
|
self.stop_node()
|
||||||
self.wait_until_stopped()
|
self.wait_until_stopped()
|
||||||
except FailedToStartError as e:
|
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.running = False
|
||||||
self.process = None
|
self.process = None
|
||||||
# Check stderr for expected message
|
# Check stderr for expected message
|
||||||
|
@ -300,9 +300,9 @@ class TestNode():
|
||||||
'Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr))
|
'Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr))
|
||||||
else:
|
else:
|
||||||
if expected_msg is None:
|
if expected_msg is None:
|
||||||
assert_msg = "bitcoind should have exited with an error"
|
assert_msg = "lbrycrdd should have exited with an error"
|
||||||
else:
|
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)
|
self._raise_assertion_error(assert_msg)
|
||||||
|
|
||||||
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
|
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
|
||||||
|
|
|
@ -292,7 +292,7 @@ def initialize_datadir(dirname, n):
|
||||||
datadir = get_datadir_path(dirname, n)
|
datadir = get_datadir_path(dirname, n)
|
||||||
if not os.path.isdir(datadir):
|
if not os.path.isdir(datadir):
|
||||||
os.makedirs(datadir)
|
os.makedirs(datadir)
|
||||||
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("regtest=1\n")
|
f.write("regtest=1\n")
|
||||||
f.write("[regtest]\n")
|
f.write("[regtest]\n")
|
||||||
f.write("port=" + str(p2p_port(n)) + "\n")
|
f.write("port=" + str(p2p_port(n)) + "\n")
|
||||||
|
@ -310,15 +310,15 @@ def get_datadir_path(dirname, n):
|
||||||
return os.path.join(dirname, "node" + str(n))
|
return os.path.join(dirname, "node" + str(n))
|
||||||
|
|
||||||
def append_config(datadir, options):
|
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:
|
for option in options:
|
||||||
f.write(option + "\n")
|
f.write(option + "\n")
|
||||||
|
|
||||||
def get_auth_cookie(datadir):
|
def get_auth_cookie(datadir):
|
||||||
user = None
|
user = None
|
||||||
password = None
|
password = None
|
||||||
if os.path.isfile(os.path.join(datadir, "bitcoin.conf")):
|
if os.path.isfile(os.path.join(datadir, "lbrycrd.conf")):
|
||||||
with open(os.path.join(datadir, "bitcoin.conf"), 'r', encoding='utf8') as f:
|
with open(os.path.join(datadir, "lbrycrd.conf"), 'r', encoding='utf8') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith("rpcuser="):
|
if line.startswith("rpcuser="):
|
||||||
assert user is None # Ensure that there is only one rpcuser line
|
assert user is None # Ensure that there is only one rpcuser line
|
||||||
|
|
|
@ -237,7 +237,7 @@ def main():
|
||||||
|
|
||||||
logging.debug("Temporary test directory at %s" % tmpdir)
|
logging.debug("Temporary test directory at %s" % tmpdir)
|
||||||
|
|
||||||
enable_bitcoind = config["components"].getboolean("ENABLE_BITCOIND")
|
enable_lbrycrdd = config["components"].getboolean("ENABLE_LBRYCRDD")
|
||||||
|
|
||||||
if config["environment"]["EXEEXT"] == ".exe" and not args.force:
|
if config["environment"]["EXEEXT"] == ".exe" and not args.force:
|
||||||
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
|
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
|
||||||
|
@ -245,7 +245,7 @@ def main():
|
||||||
print("Tests currently disabled on Windows by default. Use --force option to enable")
|
print("Tests currently disabled on Windows by default. Use --force option to enable")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if not enable_bitcoind:
|
if not enable_lbrycrdd:
|
||||||
print("No functional tests to run.")
|
print("No functional tests to run.")
|
||||||
print("Rerun ./configure with --with-daemon and then make")
|
print("Rerun ./configure with --with-daemon and then make")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -309,10 +309,10 @@ 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):
|
def run_tests(test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False):
|
||||||
args = args or []
|
args = args or []
|
||||||
|
|
||||||
# Warn if bitcoind is already running (unix only)
|
# Warn if lbrycrdd is already running (unix only)
|
||||||
try:
|
try:
|
||||||
if subprocess.check_output(["pidof", "bitcoind"]) is not None:
|
if subprocess.check_output(["pidof", "lbrycrdd"]) is not None:
|
||||||
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]))
|
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):
|
except (OSError, subprocess.SubprocessError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test multiwallet.
|
"""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 os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test the zapwallettxes functionality.
|
"""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.
|
- 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
|
- restart node 0 and verify that both the confirmed and the unconfirmed
|
||||||
transactions are still available.
|
transactions are still available.
|
||||||
|
|
|
@ -53,11 +53,13 @@ EXPECTED_BOOST_INCLUDES=(
|
||||||
boost/algorithm/string/split.hpp
|
boost/algorithm/string/split.hpp
|
||||||
boost/bind.hpp
|
boost/bind.hpp
|
||||||
boost/chrono/chrono.hpp
|
boost/chrono/chrono.hpp
|
||||||
|
boost/container/flat_map.hpp
|
||||||
boost/date_time/posix_time/posix_time.hpp
|
boost/date_time/posix_time/posix_time.hpp
|
||||||
boost/filesystem.hpp
|
boost/filesystem.hpp
|
||||||
boost/filesystem/detail/utf8_codecvt_facet.hpp
|
boost/filesystem/detail/utf8_codecvt_facet.hpp
|
||||||
boost/filesystem/fstream.hpp
|
boost/filesystem/fstream.hpp
|
||||||
boost/interprocess/sync/file_lock.hpp
|
boost/interprocess/sync/file_lock.hpp
|
||||||
|
boost/locale.hpp
|
||||||
boost/multi_index/hashed_index.hpp
|
boost/multi_index/hashed_index.hpp
|
||||||
boost/multi_index/ordered_index.hpp
|
boost/multi_index/ordered_index.hpp
|
||||||
boost/multi_index/sequenced_index.hpp
|
boost/multi_index/sequenced_index.hpp
|
||||||
|
@ -65,10 +67,14 @@ EXPECTED_BOOST_INCLUDES=(
|
||||||
boost/optional.hpp
|
boost/optional.hpp
|
||||||
boost/preprocessor/cat.hpp
|
boost/preprocessor/cat.hpp
|
||||||
boost/preprocessor/stringize.hpp
|
boost/preprocessor/stringize.hpp
|
||||||
|
boost/scope_exit.hpp
|
||||||
boost/scoped_array.hpp
|
boost/scoped_array.hpp
|
||||||
|
boost/scoped_ptr.hpp
|
||||||
boost/signals2/connection.hpp
|
boost/signals2/connection.hpp
|
||||||
boost/signals2/last_value.hpp
|
boost/signals2/last_value.hpp
|
||||||
boost/signals2/signal.hpp
|
boost/signals2/signal.hpp
|
||||||
|
boost/test/output_test_stream.hpp
|
||||||
|
boost/test/unit_test_parameters.hpp
|
||||||
boost/test/unit_test.hpp
|
boost/test/unit_test.hpp
|
||||||
boost/thread.hpp
|
boost/thread.hpp
|
||||||
boost/thread/condition_variable.hpp
|
boost/thread/condition_variable.hpp
|
||||||
|
|
|
@ -28,7 +28,7 @@ import sys
|
||||||
def main():
|
def main():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.optionxform = str
|
config.optionxform = str
|
||||||
config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini"), encoding="utf8"))
|
config.read_file(open(os.path.join(os.path.dirname(__file__), "../config.ini"), encoding="utf8"))
|
||||||
env_conf = dict(config.items('environment'))
|
env_conf = dict(config.items('environment'))
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
|
31
test_cli.sh
Executable file
31
test_cli.sh
Executable 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
|
||||||
|
|
Loading…
Reference in a new issue