Merge pull request #4331 from pravblockc/backports-v0.18-pr10

Backports v0.18: PR's 14530 and 14365
This commit is contained in:
UdjinM6 2021-08-13 23:24:58 +03:00 committed by GitHub
commit 03bca032ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 392 additions and 102 deletions

View File

@ -8,3 +8,4 @@ export LC_ALL=C
travis_retry pip install codespell==1.13.0
travis_retry pip install flake8==3.5.0
travis_retry pip install vulture==0.29

View File

@ -17,6 +17,7 @@ RUN pip3 install pyzmq # really needed?
RUN pip3 install jinja2
RUN pip3 install flake8==3.5.0
RUN pip3 install codespell==1.13.0
RUN pip3 install vulture==0.29
# dash_hash
RUN git clone https://github.com/dashpay/dash_hash

View File

@ -15,24 +15,25 @@
#include <coins.h>
#include <node/coinstats.h>
#include <core_io.h>
#include <hash.h>
#include <consensus/validation.h>
#include <index/blockfilterindex.h>
#include <key_io.h>
#include <validation.h>
#include <index/txindex.h>
#include <policy/feerate.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/descriptor.h>
#include <streams.h>
#include <sync.h>
#include <txdb.h>
#include <txmempool.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/validation.h>
#include <hash.h>
#include <util/system.h>
#include <validation.h>
#include <validationinterface.h>
#include <warnings.h>

View File

@ -19,6 +19,7 @@
#include <rpc/blockchain.h>
#include <rpc/mining.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <shutdown.h>
#include <txmempool.h>
#include <util/fees.h>

View File

@ -9,18 +9,19 @@
#include <chainparams.h>
#include <clientversion.h>
#include <core_io.h>
#include <validation.h>
#include <net.h>
#include <net_processing.h>
#include <net_permissions.h>
#include <netbase.h>
#include <policy/policy.h>
#include <rpc/protocol.h>
#include <rpc/util.h>
#include <sync.h>
#include <timedata.h>
#include <ui_interface.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <validation.h>
#include <version.h>
#include <warnings.h>

View File

@ -10,19 +10,18 @@
#include <consensus/validation.h>
#include <core_io.h>
#include <index/txindex.h>
#include <keystore.h>
#include <validation.h>
#include <validationinterface.h>
#include <init.h>
#include <key_io.h>
#include <keystore.h>
#include <merkleblock.h>
#include <net.h>
#include <node/transaction.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <psbt.h>
#include <rpc/util.h>
#include <rpc/rawtransaction.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/script.h>
#include <script/script_error.h>
#include <script/sign.h>
@ -31,6 +30,8 @@
#include <uint256.h>
#include <util/validation.h>
#include <util/strencodings.h>
#include <validation.h>
#include <validationinterface.h>
#ifdef ENABLE_WALLET
#include <wallet/rpcwallet.h>
#endif
@ -251,7 +252,16 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
{
if (request.fHelp || (request.params.size() != 1 && request.params.size() != 2))
throw std::runtime_error(
"gettxoutproof [\"txid\",...] ( blockhash )\n"
RPCHelpMan{"gettxoutproof",
{
{"txids", RPCArg::Type::ARR,
{
{"txid", RPCArg::Type::STR_HEX, false},
},
false},
{"blockhash", RPCArg::Type::STR_HEX, true},
}}
.ToString() +
"\nReturns a hex-encoded proof that \"txid\" was included in a block.\n"
"\nNOTE: By default this function only works sometimes. This is when there is an\n"
"unspent output in the utxo for this transaction. To make it always work,\n"
@ -672,10 +682,17 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
static UniValue combinerawtransaction(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 1)
throw std::runtime_error(
"combinerawtransaction [\"hexstring\",...]\n"
RPCHelpMan{"combinerawtransaction",
{
{"txs", RPCArg::Type::ARR,
{
{"hexstring", RPCArg::Type::STR_HEX, false},
},
false},
}}
.ToString() +
"\nCombine multiple partially signed transactions into one transaction.\n"
"The combined transaction may be another partially signed transaction or a \n"
"fully signed transaction."
@ -892,7 +909,30 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() < 2 || request.params.size() > 4)
throw std::runtime_error(
"signrawtransactionwithkey \"hexstring\" [\"privatekey1\",...] ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] sighashtype )\n"
RPCHelpMan{"signrawtransactionwithkey",
{
{"hexstring", RPCArg::Type::STR, false},
{"privkyes", RPCArg::Type::ARR,
{
{"privatekey", RPCArg::Type::STR_HEX, false},
},
false},
{"prevtxs", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"txid", RPCArg::Type::STR_HEX, false},
{"vout", RPCArg::Type::NUM, false},
{"scriptPubKey", RPCArg::Type::STR_HEX, false},
{"redeemScript", RPCArg::Type::STR_HEX, false},
{"amount", RPCArg::Type::AMOUNT, false},
},
true},
},
true},
{"sighashtype", RPCArg::Type::STR, true},
}}
.ToString() +
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
"The second argument is an array of base58-encoded private\n"
"keys that will be the only keys used to sign the transaction.\n"
@ -1445,7 +1485,15 @@ UniValue combinepsbt(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 1)
throw std::runtime_error(
"combinepsbt [\"psbt\",...]\n"
RPCHelpMan{"combinepsbt",
{
{"txs", RPCArg::Type::ARR,
{
{"psbt", RPCArg::Type::STR_HEX, false},
},
false},
}}
.ToString() +
"\nCombine multiple partially signed Dash transactions into one transaction.\n"
"Implements the Combiner role.\n"
"\nArguments:\n"
@ -1551,7 +1599,36 @@ UniValue createpsbt(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() < 2 || request.params.size() > 4)
throw std::runtime_error(
"createpsbt [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime )\n"
RPCHelpMan{"createpsbt",
{
{"inputs", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"txid", RPCArg::Type::STR_HEX, false},
{"vout", RPCArg::Type::NUM, false},
{"sequence", RPCArg::Type::NUM, true},
},
false},
},
false},
{"outputs", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"address", RPCArg::Type::AMOUNT, false},
},
true},
{"", RPCArg::Type::OBJ,
{
{"data", RPCArg::Type::STR_HEX, false},
},
true},
},
false},
{"locktime", RPCArg::Type::NUM, true},
}}
.ToString() +
"\nCreates a transaction in the Partially Signed Transaction format.\n"
"Implements the Creator role.\n"
"\nArguments:\n"

View File

@ -9,11 +9,12 @@
#include <fs.h>
#include <key_io.h>
#include <random.h>
#include <rpc/util.h>
#include <shutdown.h>
#include <sync.h>
#include <ui_interface.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <boost/bind.hpp>
#include <boost/signals2/signal.hpp>

View File

@ -93,6 +93,98 @@ UniValue DescribeAddress(const CTxDestination& dest)
return boost::apply_visitor(DescribeAddressVisitor(), dest);
}
std::string RPCHelpMan::ToString() const
{
std::string ret;
ret += m_name;
bool is_optional{false};
for (const auto& arg : m_args) {
ret += " ";
if (arg.m_optional) {
if (!is_optional) ret += "( ";
is_optional = true;
} else {
// Currently we still support unnamed arguments, so any argument following an optional argument must also be optional
// If support for positional arguments is deprecated in the future, remove this line
assert(!is_optional);
}
ret += arg.ToString();
}
if (is_optional) ret += " )";
ret += "\n";
return ret;
}
std::string RPCArg::ToStringObj() const
{
std::string res = "\"" + m_name + "\":";
switch (m_type) {
case Type::STR:
return res + "\"str\"";
case Type::STR_HEX:
return res + "\"hex\"";
case Type::NUM:
return res + "n";
case Type::AMOUNT:
return res + "amount";
case Type::BOOL:
return res + "bool";
case Type::ARR:
res += "[";
for (const auto& i : m_inner) {
res += i.ToString() + ",";
}
return res + "...]";
case Type::OBJ:
case Type::OBJ_USER_KEYS:
// Currently unused, so avoid writing dead code
assert(false);
// no default case, so the compiler can warn about missing cases
}
assert(false);
}
std::string RPCArg::ToString() const
{
switch (m_type) {
case Type::STR_HEX:
case Type::STR: {
return "\"" + m_name + "\"";
}
case Type::NUM:
case Type::AMOUNT:
case Type::BOOL: {
return m_name;
}
case Type::OBJ:
case Type::OBJ_USER_KEYS: {
std::string res;
for (size_t i = 0; i < m_inner.size();) {
res += m_inner[i].ToStringObj();
if (++i < m_inner.size()) res += ",";
}
if (m_type == Type::OBJ) {
return "{" + res + "}";
} else {
return "{" + res + ",...}";
}
}
case Type::ARR: {
std::string res;
for (const auto& i : m_inner) {
res += i.ToString() + ",";
}
return "[" + res + "...]";
}
// no default case, so the compiler can warn about missing cases
}
assert(false);
}
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
{
switch (terr) {

View File

@ -25,6 +25,55 @@ CScript CreateMultisigRedeemscript(const int required, const std::vector<CPubKey
UniValue DescribeAddress(const CTxDestination& dest);
struct RPCArg {
enum class Type {
OBJ,
ARR,
STR,
NUM,
BOOL,
OBJ_USER_KEYS, //!< Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e.g. an options object where the keys are predefined
AMOUNT, //!< Special type representing a floating point amount (can be either NUM or STR)
STR_HEX, //!< Special type that is a STR with only hex chars
};
const std::string m_name; //!< The name of the arg (can be empty for inner args)
const Type m_type;
const std::vector<RPCArg> m_inner; //!< Only used for arrays or dicts
const bool m_optional;
RPCArg(const std::string& name, const Type& type, const bool optional)
: m_name{name}, m_type{type}, m_optional{optional}
{
assert(type != Type::ARR && type != Type::OBJ);
}
RPCArg(const std::string& name, const Type& type, const std::vector<RPCArg>& inner, const bool optional)
: m_name{name}, m_type{type}, m_inner{inner}, m_optional{optional}
{
assert(type == Type::ARR || type == Type::OBJ);
}
std::string ToString() const;
private:
std::string ToStringObj() const;
};
class RPCHelpMan
{
public:
RPCHelpMan(const std::string& name, const std::vector<RPCArg>& args)
: m_name{name}, m_args{args}
{
}
std::string ToString() const;
private:
const std::string m_name;
const std::vector<RPCArg> m_args;
};
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr);
UniValue JSONRPCTransactionError(TransactionError terr, const std::string& err_string = "");

View File

@ -4,17 +4,18 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chain.h>
#include <rpc/server.h>
#include <validation.h>
#include <core_io.h>
#include <key_io.h>
#include <merkleblock.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/script.h>
#include <script/standard.h>
#include <sync.h>
#include <util/system.h>
#include <util/time.h>
#include <validation.h>
#include <wallet/wallet.h>
#include <merkleblock.h>
#include <core_io.h>
#include <wallet/rpcwallet.h>

View File

@ -2735,7 +2735,21 @@ static UniValue lockunspent(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw std::runtime_error(
"lockunspent unlock ([{\"txid\":\"txid\",\"vout\":n},...])\n"
RPCHelpMan{"lockunspent",
{
{"unlock", RPCArg::Type::BOOL, false},
{"transactions", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"txid", RPCArg::Type::STR_HEX, false},
{"vout", RPCArg::Type::NUM, false},
},
true},
},
true},
}}
.ToString() +
"\nUpdates list of temporarily unspendable outputs.\n"
"Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n"
"If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n"
@ -3500,7 +3514,26 @@ static UniValue listunspent(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() > 5)
throw std::runtime_error(
"listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] [query_options])\n"
RPCHelpMan{"listunspent",
{
{"minconf", RPCArg::Type::NUM, true},
{"maxconf", RPCArg::Type::NUM, true},
{"addresses", RPCArg::Type::ARR,
{
{"address", RPCArg::Type::STR_HEX, true},
},
true},
{"include_unsafe", RPCArg::Type::BOOL, true},
{"query_options", RPCArg::Type::OBJ,
{
{"minimumAmount", RPCArg::Type::AMOUNT, true},
{"maximumAmount", RPCArg::Type::AMOUNT, true},
{"maximumCount", RPCArg::Type::NUM, true},
{"minimumSumAmount", RPCArg::Type::AMOUNT, true},
},
true},
}}
.ToString() +
"\nReturns array of unspent transaction outputs\n"
"with between minconf and maxconf (inclusive) confirmations.\n"
"Optionally filter to only include txouts paid to specified addresses.\n"
@ -3886,7 +3919,25 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw std::runtime_error(
"signrawtransactionwithwallet \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] sighashtype )\n"
RPCHelpMan{"signrawtransactionwithwallet",
{
{"hexstring", RPCArg::Type::STR, false},
{"prevtxs", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"txid", RPCArg::Type::STR_HEX, false},
{"vout", RPCArg::Type::NUM, false},
{"scriptPubKey", RPCArg::Type::STR_HEX, false},
{"redeemScript", RPCArg::Type::STR_HEX, false},
{"amount", RPCArg::Type::AMOUNT, false},
},
false},
},
true},
{"sighashtype", RPCArg::Type::STR, true},
}}
.ToString() +
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
"The second optional argument (may be null) is an array of previous transaction outputs that\n"
"this transaction depends on but may not yet be in the block chain.\n"
@ -4479,7 +4530,54 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 2 || request.params.size() > 6)
throw std::runtime_error(
"walletcreatefundedpsbt [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime ) ( options bip32derivs )\n"
RPCHelpMan{"walletcreatefundedpsbt",
{
{"inputs", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"txid", RPCArg::Type::STR_HEX, false},
{"vout", RPCArg::Type::NUM, false},
{"sequence", RPCArg::Type::NUM, false},
},
false},
},
false},
{"outputs", RPCArg::Type::ARR,
{
{"", RPCArg::Type::OBJ,
{
{"address", RPCArg::Type::AMOUNT, true},
},
true},
{"", RPCArg::Type::OBJ,
{
{"data", RPCArg::Type::STR_HEX, true},
},
true},
},
false},
{"locktime", RPCArg::Type::NUM, true},
{"options", RPCArg::Type::OBJ,
{
{"changeAddress", RPCArg::Type::STR_HEX, true},
{"changePosition", RPCArg::Type::NUM, true},
{"change_type", RPCArg::Type::STR, true},
{"includeWatching", RPCArg::Type::BOOL, true},
{"lockUnspents", RPCArg::Type::BOOL, true},
{"feeRate", RPCArg::Type::NUM, true},
{"subtractFeeFromOutputs", RPCArg::Type::ARR,
{
{"int", RPCArg::Type::NUM, true},
},
true},
{"conf_target", RPCArg::Type::NUM, true},
{"estimate_mode", RPCArg::Type::STR, true},
},
true},
{"bip32derivs", RPCArg::Type::BOOL, true},
}}
.ToString() +
"\nCreates and funds a transaction in the Partially Signed Transaction format. Inputs will be added if supplied inputs are not enough\n"
"Implements the Creator and Updater roles.\n"
"\nArguments:\n"

View File

@ -5,6 +5,7 @@
#include <zmq/zmqrpc.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <zmq/zmqabstractnotifier.h>
#include <zmq/zmqnotificationinterface.h>

View File

@ -33,7 +33,6 @@ class AddressIndexTest(BitcoinTestFramework):
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.is_network_split = False
self.sync_all()
def run_test(self):

View File

@ -151,7 +151,7 @@ class BlockRewardReallocationTest(DashTestFramework):
assert_equal(bt['masternode'][0]['amount'], 6874285801) # 0.4999999998
self.log.info("Reallocation should kick-in with the superblock mined at height = 2010")
for period in range(19): # there will be 19 adjustments, 3 superblocks long each
for _ in range(19): # there will be 19 adjustments, 3 superblocks long each
for i in range(3):
self.bump_mocktime(10)
self.nodes[0].generate(10)
@ -163,7 +163,7 @@ class BlockRewardReallocationTest(DashTestFramework):
assert_equal(bt['masternode'][0]['amount'], 6132959502) # 0.6
self.log.info("Reward split should stay ~60/40 after reallocation is done")
for period in range(10): # check 10 next superblocks
for _ in range(10): # check 10 next superblocks
self.bump_mocktime(10)
self.nodes[0].generate(10)
bt = self.nodes[0].getblocktemplate()

View File

@ -40,14 +40,6 @@ class DIP3Test(BitcoinTestFramework):
if i < len(self.nodes) and self.nodes[i] is not None and self.nodes[i].process is not None:
connect_nodes(self.nodes[i], 0)
def stop_controller_node(self):
self.log.info("stopping controller node")
self.stop_node(0)
def restart_controller_node(self):
self.stop_controller_node()
self.start_controller_node()
def run_test(self):
self.log.info("funding controller node")
while self.nodes[0].getbalance() < (self.num_initial_mn + 3) * 1000:
@ -216,7 +208,6 @@ class DIP3Test(BitcoinTestFramework):
mn = Masternode()
mn.idx = idx
mn.alias = alias
mn.is_protx = True
mn.p2p_port = p2p_port(mn.idx)
blsKey = node.bls('generate')

View File

@ -23,7 +23,6 @@ class MultiKeySporkTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 5
self.setup_clean_chain = True
self.is_network_split = False
def setup_network(self):
# secret(base58): 931wyuRNVYvhg18Uu9bky5Qg1z4QbxaJ7fefNBzjBPiLRqcd33F

View File

@ -35,7 +35,6 @@ class SpentIndexTest(BitcoinTestFramework):
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.is_network_split = False
self.sync_all()
def run_test(self):

View File

@ -30,7 +30,6 @@ class TimestampIndexTest(BitcoinTestFramework):
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.is_network_split = False
self.sync_all()
def run_test(self):

View File

@ -33,7 +33,6 @@ class TxIndexTest(BitcoinTestFramework):
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.is_network_split = False
self.sync_all()
def run_test(self):

View File

@ -27,8 +27,9 @@ class MempoolExpiryTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
# TODO: enable when skip_if_no_wallet is backported
# def skip_test_if_missing_module(self):
# self.skip_if_no_wallet()
def test_transaction_expiry(self, timeout):
"""Tests that a transaction expires after the expiry timeout and its

View File

@ -21,8 +21,9 @@ class P2PLeakTxTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
# TODO: enable when skip_if_no_wallet is backported
# def skip_test_if_missing_module(self):
# self.skip_if_no_wallet()
def run_test(self):
gen_node = self.nodes[0] # The block and tx generating node

View File

@ -86,9 +86,6 @@ ssl.EC_KEY_new_by_curve_name.errcheck = _check_result
class CECKey():
"""Wrapper around OpenSSL's EC_KEY"""
POINT_CONVERSION_COMPRESSED = 2
POINT_CONVERSION_UNCOMPRESSED = 4
def __init__(self):
self.k = ssl.EC_KEY_new_by_curve_name(NID_secp256k1)
@ -181,13 +178,6 @@ class CECKey():
"""Verify a DER signature"""
return ssl.ECDSA_verify(0, hash, len(hash), sig, len(sig), self.k) == 1
def set_compressed(self, compressed):
if compressed:
form = self.POINT_CONVERSION_COMPRESSED
else:
form = self.POINT_CONVERSION_UNCOMPRESSED
ssl.EC_KEY_set_conv_form(self.k, form)
class CPubKey(bytes):
"""An encapsulated public key

View File

@ -36,7 +36,6 @@ MY_VERSION = 70219 # LLMQ_DATA_MESSAGES_VERSION
MY_SUBVERSION = b"/python-mininode-tester:0.0.3%s/"
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
MAX_INV_SZ = 50000
MAX_LOCATOR_SZ = 101
MAX_BLOCK_SIZE = 1000000
@ -166,22 +165,6 @@ def ser_uint256_vector(l):
return r
def deser_string_vector(f):
nit = deser_compact_size(f)
r = []
for i in range(nit):
t = deser_string(f)
r.append(t)
return r
def ser_string_vector(l):
r = ser_compact_size(len(l))
for sv in l:
r += ser_string(sv)
return r
def deser_dyn_bitset(f, bytes_based):
if bytes_based:
nb = deser_compact_size(f)
@ -831,13 +814,12 @@ class BlockTransactions:
class CPartialMerkleTree:
__slots__ = ("fBad", "nTransactions", "vBits", "vHash")
__slots__ = ("nTransactions", "vBits", "vHash")
def __init__(self):
self.nTransactions = 0
self.vBits = []
self.vHash = []
self.fBad = False
def deserialize(self, f):
self.nTransactions = struct.unpack("<I", f.read(4))[0]

View File

@ -400,8 +400,7 @@ class P2PInterface(P2PConnection):
def on_qdata(self, message): pass
def on_qwatch(self, message): pass
def on_verack(self, message):
self.verack_received = True
def on_verack(self, message): pass
def on_version(self, message):
assert message.nVersion >= MIN_VERSION_SUPPORTED, "Version {} received. Test framework only supports versions greater than {}".format(message.nVersion, MIN_VERSION_SUPPORTED)
@ -474,18 +473,19 @@ class P2PInterface(P2PConnection):
wait_until(test_function, timeout=timeout, lock=mininode_lock)
def wait_for_inv(self, expected_inv, timeout=60):
"""Waits for an INV message and checks that the first inv object in the message was as expected."""
if len(expected_inv) > 1:
raise NotImplementedError("wait_for_inv() will only verify the first inv object")
# TODO: enable when p2p_filter.py is backported
# def wait_for_inv(self, expected_inv, timeout=60):
# """Waits for an INV message and checks that the first inv object in the message was as expected."""
# if len(expected_inv) > 1:
# raise NotImplementedError("wait_for_inv() will only verify the first inv object")
def test_function():
assert self.is_connected
return self.last_message.get("inv") and \
self.last_message["inv"].inv[0].type == expected_inv[0].type and \
self.last_message["inv"].inv[0].hash == expected_inv[0].hash
# def test_function():
# assert self.is_connected
# return self.last_message.get("inv") and \
# self.last_message["inv"].inv[0].type == expected_inv[0].type and \
# self.last_message["inv"].inv[0].hash == expected_inv[0].hash
wait_until(test_function, timeout=timeout, lock=mininode_lock)
# wait_until(test_function, timeout=timeout, lock=mininode_lock)
def wait_for_verack(self, timeout=60):
def test_function():

View File

@ -54,10 +54,9 @@ class Socks5Command():
return 'Socks5Command(%s,%s,%s,%s,%s,%s)' % (self.cmd, self.atyp, self.addr, self.port, self.username, self.password)
class Socks5Connection():
def __init__(self, serv, conn, peer):
def __init__(self, serv, conn):
self.serv = serv
self.conn = conn
self.peer = peer
def handle(self):
"""Handle socks5 request according to RFC192."""
@ -137,9 +136,9 @@ class Socks5Server():
def run(self):
while self.running:
(sockconn, peer) = self.s.accept()
(sockconn, _) = self.s.accept()
if self.running:
conn = Socks5Connection(self, sockconn, peer)
conn = Socks5Connection(self, sockconn)
thread = threading.Thread(None, conn.handle)
thread.daemon = True
thread.start()

View File

@ -575,7 +575,6 @@ class DashTestFramework(BitcoinTestFramework):
self.num_nodes = num_nodes
self.mninfo = []
self.setup_clean_chain = True
self.is_network_split = False
# additional args
if extra_args is None:
extra_args = [[]] * num_nodes

View File

@ -4,20 +4,9 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the listtransactions API."""
from decimal import Decimal
from io import BytesIO
from test_framework.messages import CTransaction
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_array_result,
hex_str_to_bytes,
)
def tx_from_hex(hexstring):
tx = CTransaction()
f = BytesIO(hex_str_to_bytes(hexstring))
tx.deserialize(f)
return tx
from test_framework.util import assert_array_result
class ListTransactionsTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -0,0 +1,19 @@
#!/bin/bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Find dead Python code.
export LC_ALL=C
if ! command -v vulture > /dev/null; then
echo "Skipping Python dead code linting since vulture is not installed. Install by running \"pip3 install vulture\""
exit 0
fi
vulture \
--min-confidence 60 \
--ignore-names "argtypes,connection_lost,connection_made,converter,data_received,daemon,errcheck,get_ecdh_key,get_privkey,is_compressed,is_fullyvalid,msg_generic,on_*,optionxform,restype,set_privkey,*serialize_v2" \
$(git ls-files -- "*.py" ":(exclude)contrib/" ":(exclude)src/crc32c/" ":(exclude)test/functional/test_framework/address.py")