aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xqa/pull-tester/rpc-tests.py125
-rw-r--r--src/rpc/blockchain.cpp29
-rw-r--r--src/txdb.cpp6
-rw-r--r--src/wallet/rpcwallet.cpp4
4 files changed, 86 insertions, 78 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py
index 6d3bda10ee..c0637209e3 100755
--- a/qa/pull-tester/rpc-tests.py
+++ b/qa/pull-tester/rpc-tests.py
@@ -40,15 +40,6 @@ if 'ENABLE_UTILS' not in vars():
ENABLE_UTILS=0
if 'ENABLE_ZMQ' not in vars():
ENABLE_ZMQ=0
-
-# python-zmq may not be installed. Handle this gracefully and with some helpful info
-if ENABLE_ZMQ:
- try:
- import zmq
- except ImportError:
- print("WARNING: \"import zmq\" failed. Setting ENABLE_ZMQ=0. " \
- "To run zmq tests, see dependency info in /qa/README.md.")
- ENABLE_ZMQ=0
ENABLE_COVERAGE=0
@@ -76,11 +67,25 @@ if "BITCOIND" not in os.environ:
if "BITCOINCLI" not in os.environ:
os.environ["BITCOINCLI"] = buildDir + '/src/bitcoin-cli' + EXEEXT
-#Disable Windows tests by default
if EXEEXT == ".exe" and "-win" not in opts:
- print "Win tests currently disabled. Use -win option to enable"
+ # https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
+ # https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
+ print "Win tests currently disabled by default. Use -win option to enable"
+ sys.exit(0)
+
+if not (ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
+ print "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled"
sys.exit(0)
+# python-zmq may not be installed. Handle this gracefully and with some helpful info
+if ENABLE_ZMQ:
+ try:
+ import zmq
+ except ImportError as e:
+ print("ERROR: \"import zmq\" failed. Set ENABLE_ZMQ=0 or " \
+ "to run zmq tests, see dependency info in /qa/README.md.")
+ raise e
+
#Tests
testScripts = [
'bip68-112-113-p2p.py',
@@ -119,6 +124,9 @@ testScripts = [
'p2p-versionbits-warning.py',
'importprunedfunds.py',
]
+if ENABLE_ZMQ:
+ testScripts.append('zmq_test.py')
+
testScriptsExt = [
'bip9-softforks.py',
'bip65-cltv.py',
@@ -143,11 +151,6 @@ testScriptsExt = [
'pruning.py', # leave pruning last as it takes a REALLY long time
]
-#Enable ZMQ tests
-if ENABLE_ZMQ == 1:
- testScripts.append('zmq_test.py')
-
-
def runtests():
coverage = None
@@ -155,53 +158,49 @@ def runtests():
coverage = RPCCoverage()
print("Initializing coverage directory at %s\n" % coverage.dir)
- if(ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
- rpcTestDir = buildDir + '/qa/rpc-tests/'
- run_extended = '-extended' in opts
- cov_flag = coverage.flag if coverage else ''
- flags = " --srcdir %s/src %s %s" % (buildDir, cov_flag, passOn)
-
- #Run Tests
- for i in range(len(testScripts)):
- if (len(opts) == 0
- or (len(opts) == 1 and "-win" in opts )
- or run_extended
- or testScripts[i] in opts
- or re.sub(".py$", "", testScripts[i]) in opts ):
-
- print("Running testscript %s%s%s ..." % (bold[1], testScripts[i], bold[0]))
- time0 = time.time()
- subprocess.check_call(
- rpcTestDir + testScripts[i] + flags, shell=True)
- print("Duration: %s s\n" % (int(time.time() - time0)))
-
- # exit if help is called so we print just one set of
- # instructions
- p = re.compile(" -h| --help")
- if p.match(passOn):
- sys.exit(0)
-
- # Run Extended Tests
- for i in range(len(testScriptsExt)):
- if (run_extended or testScriptsExt[i] in opts
- or re.sub(".py$", "", testScriptsExt[i]) in opts):
-
- print(
- "Running 2nd level testscript "
- + "%s%s%s ..." % (bold[1], testScriptsExt[i], bold[0]))
- time0 = time.time()
- subprocess.check_call(
- rpcTestDir + testScriptsExt[i] + flags, shell=True)
- print("Duration: %s s\n" % (int(time.time() - time0)))
-
- if coverage:
- coverage.report_rpc_coverage()
-
- print("Cleaning up coverage data")
- coverage.cleanup()
-
- else:
- print "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled"
+ rpcTestDir = buildDir + '/qa/rpc-tests/'
+ run_extended = '-extended' in opts
+ cov_flag = coverage.flag if coverage else ''
+ flags = " --srcdir %s/src %s %s" % (buildDir, cov_flag, passOn)
+
+ #Run Tests
+ for i in range(len(testScripts)):
+ if (len(opts) == 0
+ or (len(opts) == 1 and "-win" in opts )
+ or run_extended
+ or testScripts[i] in opts
+ or re.sub(".py$", "", testScripts[i]) in opts ):
+
+ print("Running testscript %s%s%s ..." % (bold[1], testScripts[i], bold[0]))
+ time0 = time.time()
+ subprocess.check_call(
+ rpcTestDir + testScripts[i] + flags, shell=True)
+ print("Duration: %s s\n" % (int(time.time() - time0)))
+
+ # exit if help is called so we print just one set of
+ # instructions
+ p = re.compile(" -h| --help")
+ if p.match(passOn):
+ sys.exit(0)
+
+ # Run Extended Tests
+ for i in range(len(testScriptsExt)):
+ if (run_extended or testScriptsExt[i] in opts
+ or re.sub(".py$", "", testScriptsExt[i]) in opts):
+
+ print(
+ "Running 2nd level testscript "
+ + "%s%s%s ..." % (bold[1], testScriptsExt[i], bold[0]))
+ time0 = time.time()
+ subprocess.check_call(
+ rpcTestDir + testScriptsExt[i] + flags, shell=True)
+ print("Duration: %s s\n" % (int(time.time() - time0)))
+
+ if coverage:
+ coverage.report_rpc_coverage()
+
+ print("Cleaning up coverage data")
+ coverage.cleanup()
class RPCCoverage(object):
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 88f6278b2a..5de2394e24 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -815,17 +815,30 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
LOCK(cs_main);
- /* Build up a list of chain tips. We start with the list of all
- known blocks, and successively remove blocks that appear as pprev
- of another block. */
+ /*
+ * Idea: the set of chain tips is chainActive.tip, plus orphan blocks which do not have another orphan building off of them.
+ * Algorithm:
+ * - Make one pass through mapBlockIndex, picking out the orphan blocks, and also storing a set of the orphan block's pprev pointers.
+ * - Iterate through the orphan blocks. If the block isn't pointed to by another orphan, it is a chain tip.
+ * - add chainActive.Tip()
+ */
std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
- BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
- setTips.insert(item.second);
+ std::set<const CBlockIndex*> setOrphans;
+ std::set<const CBlockIndex*> setPrevs;
+
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
{
- const CBlockIndex* pprev = item.second->pprev;
- if (pprev)
- setTips.erase(pprev);
+ if (!chainActive.Contains(item.second)) {
+ setOrphans.insert(item.second);
+ setPrevs.insert(item.second->pprev);
+ }
+ }
+
+ for (std::set<const CBlockIndex*>::iterator it = setOrphans.begin(); it != setOrphans.end(); ++it)
+ {
+ if (setPrevs.erase(*it) == 0) {
+ setTips.insert(*it);
+ }
}
// Always report the currently active tip.
diff --git a/src/txdb.cpp b/src/txdb.cpp
index be86cceeb3..19ca178654 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -134,12 +134,8 @@ bool CCoinsViewDBCursor::Valid() const
void CCoinsViewDBCursor::Next()
{
pcursor->Next();
- if (pcursor->Valid()) {
- bool ok = pcursor->GetKey(keyTmp);
- assert(ok); // If GetKey fails here something must be wrong with underlying database, we cannot handle that here
- } else {
+ if (!pcursor->Valid() || !pcursor->GetKey(keyTmp))
keyTmp.first = 0; // Invalidate cached key after last record so that Valid() and GetKey() return false
- }
}
bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 3078cebd48..d1e201ec11 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -2443,7 +2443,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
"Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n"
"The inputs added will not be signed, use signrawtransaction for that.\n"
"Note that all existing inputs must have their previous output transaction be in the wallet.\n"
- "Note that all inputs selected must be of standard form and P2SH scripts must be"
+ "Note that all inputs selected must be of standard form and P2SH scripts must be\n"
"in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
"Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n"
"\nArguments:\n"
@@ -2455,7 +2455,7 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp)
" \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n"
" \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n"
" }\n"
- " for backward compatibility: passing in a true instzead of an object will result in {\"includeWatching\":true}\n"
+ " for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n"
"\nResult:\n"
"{\n"
" \"hex\": \"value\", (string) The resulting raw transaction (hex-encoded string)\n"