Merge pull request #4315 from pravblockc/backports-v0.18-pr6

Backports v0.18 PR's: 14805, 14947 and 14953
This commit is contained in:
PastaPastaPasta 2021-08-06 16:17:59 -05:00 committed by GitHub
commit ff2048a8be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 50 deletions

View File

@ -14,7 +14,6 @@
# In case of a clean merge that is accepted by the user, the local branch with
# name $BRANCH is overwritten with the merged result, and optionally pushed.
from __future__ import division,print_function,unicode_literals
import os
from sys import stdin,stdout,stderr
import argparse
@ -23,10 +22,7 @@ import subprocess
import sys
import json
import codecs
try:
from urllib.request import Request,urlopen
except:
from urllib2 import Request,urlopen
from urllib.request import Request, urlopen
# External tools (can be overridden using environment)
GIT = os.getenv('GIT','git')

View File

@ -7,7 +7,6 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from __future__ import print_function, division
import struct
import re
import os

View File

@ -7,11 +7,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from __future__ import print_function
try: # Python 3
import http.client as httplib
except ImportError: # Python 2
import httplib
from http.client import HttpConnection
import json
import re
import base64
@ -31,7 +27,7 @@ class BitcoinRPC:
authpair = "%s:%s" % (username, password)
authpair = authpair.encode('utf-8')
self.authhdr = b"Basic " + base64.b64encode(authpair)
self.conn = httplib.HTTPConnection(host, port=port, timeout=30)
self.conn = HttpConnection(host, port=port, timeout=30)
def execute(self, obj):
try:

View File

@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerLogicValidation &peerLogic, CConnmanTest* connman)
{
CAddress addr(ip(insecure_rand_ctx.randbits(32)), NODE_NONE);
CAddress addr(ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE);
vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK), 0, INVALID_SOCKET, addr, 0, 0, CAddress(), "", /*fInboundIn=*/ false));
CNode &node = *vNodes.back();
node.SetSendVersion(PROTOCOL_VERSION);

View File

@ -12,6 +12,7 @@
#include <index/txindex.h>
#include <miner.h>
#include <net_processing.h>
#include <noui.h>
#include <pow.h>
#include <rpc/register.h>
#include <rpc/server.h>
@ -30,10 +31,7 @@
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
FastRandomContext insecure_rand_ctx;
extern bool fPrintToConsole;
extern void noui_connect();
thread_local FastRandomContext g_insecure_rand_ctx;
std::ostream& operator<<(std::ostream& os, const uint256& num)
{
@ -116,23 +114,23 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
TestingSetup::~TestingSetup()
{
llmq::InterruptLLMQSystem();
llmq::StopLLMQSystem();
g_txindex->Interrupt();
g_txindex->Stop();
g_txindex.reset();
threadGroup.interrupt_all();
threadGroup.join_all();
StopScriptCheckWorkerThreads();
GetMainSignals().FlushBackgroundCallbacks();
GetMainSignals().UnregisterBackgroundSignalScheduler();
g_connman.reset();
g_banman.reset();
UnloadBlockIndex();
pcoinsTip.reset();
llmq::DestroyLLMQSystem();
pcoinsdbview.reset();
pblocktree.reset();
llmq::InterruptLLMQSystem();
llmq::StopLLMQSystem();
g_txindex->Interrupt();
g_txindex->Stop();
g_txindex.reset();
threadGroup.interrupt_all();
threadGroup.join_all();
StopScriptCheckWorkerThreads();
GetMainSignals().FlushBackgroundCallbacks();
GetMainSignals().UnregisterBackgroundSignalScheduler();
g_connman.reset();
g_banman.reset();
UnloadBlockIndex();
pcoinsTip.reset();
llmq::DestroyLLMQSystem();
pcoinsdbview.reset();
pblocktree.reset();
}
TestChainSetup::TestChainSetup(int blockCount) : TestingSetup(CBaseChainParams::REGTEST)

View File

@ -19,7 +19,7 @@
#include <boost/thread.hpp>
extern FastRandomContext insecure_rand_ctx;
thread_local extern FastRandomContext g_insecure_rand_ctx;
/**
* Flag to make GetRand in random.h return the same number
@ -28,14 +28,14 @@ extern bool g_mock_deterministic_tests;
static inline void SeedInsecureRand(bool deterministic = false)
{
insecure_rand_ctx = FastRandomContext(deterministic);
g_insecure_rand_ctx = FastRandomContext(deterministic);
}
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }
static inline uint256 InsecureRand256() { return insecure_rand_ctx.rand256(); }
static inline uint64_t InsecureRandBits(int bits) { return insecure_rand_ctx.randbits(bits); }
static inline uint64_t InsecureRandRange(uint64_t range) { return insecure_rand_ctx.randrange(range); }
static inline bool InsecureRandBool() { return insecure_rand_ctx.randbool(); }
static inline uint32_t InsecureRand32() { return g_insecure_rand_ctx.rand32(); }
static inline uint256 InsecureRand256() { return g_insecure_rand_ctx.rand256(); }
static inline uint64_t InsecureRandBits(int bits) { return g_insecure_rand_ctx.randbits(bits); }
static inline uint64_t InsecureRandRange(uint64_t range) { return g_insecure_rand_ctx.randrange(range); }
static inline bool InsecureRandBool() { return g_insecure_rand_ctx.randbool(); }
static constexpr CAmount CENT{1000000};
@ -61,7 +61,7 @@ class CConnman;
class CNode;
class PeerLogicValidation;
struct TestingSetup: public BasicTestingSetup {
struct TestingSetup : public BasicTestingSetup {
boost::thread_group threadGroup;
CScheduler scheduler;

View File

@ -319,9 +319,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
assert_equal(len(extra_confs), num_nodes)
assert_equal(len(extra_args), num_nodes)
assert_equal(len(binary), num_nodes)
old_num_nodes = len(self.nodes)
for i in range(num_nodes):
self.nodes.append(TestNode(old_num_nodes + i, get_datadir_path(self.options.tmpdir, old_num_nodes + i), self.extra_args_from_options, chain=self.chain, 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))
numnode = len(self.nodes)
self.nodes.append(TestNode(numnode, get_datadir_path(self.options.tmpdir, numnode), self.extra_args_from_options, chain=self.chain, 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))
def start_node(self, i, *args, **kwargs):
"""Start a dashd"""

View File

@ -9,14 +9,9 @@ Runs automatically during `make check`.
Can also be run manually."""
from __future__ import division,print_function,unicode_literals
import argparse
import binascii
try:
import configparser
except ImportError:
import ConfigParser as configparser
import configparser
import difflib
import json
import logging