mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge pull request #5083 from Munkybooty/backports-0.20-pr10
backport: v0.20 pr10
This commit is contained in:
commit
466cd25f64
@ -1526,7 +1526,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
|
|||||||
{RPCResult::Type::NUM_TIME, "start_time", "the minimum median time past of a block at which the bit gains its meaning"},
|
{RPCResult::Type::NUM_TIME, "start_time", "the minimum median time past of a block at which the bit gains its meaning"},
|
||||||
{RPCResult::Type::NUM_TIME, "timeout", "the median time past of a block at which the deployment is considered failed if not yet locked in"},
|
{RPCResult::Type::NUM_TIME, "timeout", "the median time past of a block at which the deployment is considered failed if not yet locked in"},
|
||||||
{RPCResult::Type::NUM, "since", "height of the first block to which the status applies"},
|
{RPCResult::Type::NUM, "since", "height of the first block to which the status applies"},
|
||||||
{RPCResult::Type::OBJ, "statistics", "numeric statistics about BIP9 signalling for a softfork",
|
{RPCResult::Type::OBJ, "statistics", "numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::NUM, "period", "the length in blocks of the BIP9 signalling period"},
|
{RPCResult::Type::NUM, "period", "the length in blocks of the BIP9 signalling period"},
|
||||||
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature"},
|
{RPCResult::Type::NUM, "threshold", "the number of blocks with the version bit set required to activate the feature"},
|
||||||
@ -2619,7 +2619,8 @@ static UniValue getblockfilter(const JSONRPCRequest& request)
|
|||||||
{RPCResult::Type::STR_HEX, "header", "the hex-encoded filter header"},
|
{RPCResult::Type::STR_HEX, "header", "the hex-encoded filter header"},
|
||||||
}},
|
}},
|
||||||
RPCExamples{
|
RPCExamples{
|
||||||
HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"")
|
HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"")+
|
||||||
|
HelpExampleRpc("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\", \"basic\"")
|
||||||
},
|
},
|
||||||
}.Check(request);
|
}.Check(request);
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ std::string HelpExampleCli(const std::string& methodname, const std::string& arg
|
|||||||
|
|
||||||
std::string HelpExampleRpc(const std::string& methodname, const std::string& args)
|
std::string HelpExampleRpc(const std::string& methodname, const std::string& args)
|
||||||
{
|
{
|
||||||
return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", "
|
return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", "
|
||||||
"\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;'"
|
"\"method\": \"" + methodname + "\", \"params\": [" + args + "]}' -H 'content-type: text/plain;'"
|
||||||
" http://127.0.0.1:9998/\n";
|
" http://127.0.0.1:9998/\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
void initialize_key_io()
|
void initialize_key_io()
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
static const ECCVerifyHandle verify_handle;
|
||||||
|
ECC_Start();
|
||||||
|
SelectParams(CBaseChainParams::MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(key_io, initialize_key_io)
|
FUZZ_TARGET_INIT(key_io, initialize_key_io)
|
||||||
|
@ -47,17 +47,20 @@ from test_framework.script import (CScript, OP_TRUE)
|
|||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (assert_equal, set_node_times)
|
from test_framework.util import (assert_equal, set_node_times)
|
||||||
|
|
||||||
|
|
||||||
class BaseNode(P2PInterface):
|
class BaseNode(P2PInterface):
|
||||||
def send_header_for_blocks(self, new_blocks):
|
def send_header_for_blocks(self, new_blocks):
|
||||||
headers_message = msg_headers()
|
headers_message = msg_headers()
|
||||||
headers_message.headers = [CBlockHeader(b) for b in new_blocks]
|
headers_message.headers = [CBlockHeader(b) for b in new_blocks]
|
||||||
self.send_message(headers_message)
|
self.send_message(headers_message)
|
||||||
|
|
||||||
|
|
||||||
class AssumeValidTest(BitcoinTestFramework):
|
class AssumeValidTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.num_nodes = 3
|
self.num_nodes = 3
|
||||||
self.extra_args = ["-dip3params=9000:9000", "-checkblockindex=0"]
|
self.extra_args = ["-dip3params=9000:9000", "-checkblockindex=0"]
|
||||||
|
self.rpc_timeout = 120
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
self.add_nodes(3)
|
self.add_nodes(3)
|
||||||
@ -197,5 +200,6 @@ class AssumeValidTest(BitcoinTestFramework):
|
|||||||
self.send_blocks_until_disconnected(p2p2)
|
self.send_blocks_until_disconnected(p2p2)
|
||||||
self.assert_blockchain_height(self.nodes[2], 101)
|
self.assert_blockchain_height(self.nodes[2], 101)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
AssumeValidTest().main()
|
AssumeValidTest().main()
|
||||||
|
@ -631,17 +631,19 @@ class FullBlockTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info("Reject a block with invalid work")
|
self.log.info("Reject a block with invalid work")
|
||||||
self.move_tip(44)
|
self.move_tip(44)
|
||||||
b47 = self.next_block(47, solve=False)
|
b47 = self.next_block(47)
|
||||||
target = uint256_from_compact(b47.nBits)
|
target = uint256_from_compact(b47.nBits)
|
||||||
while b47.sha256 <= target:
|
while b47.sha256 <= target:
|
||||||
|
# Rehash nonces until an invalid too-high-hash block is found.
|
||||||
b47.nNonce += 1
|
b47.nNonce += 1
|
||||||
b47.rehash()
|
b47.rehash()
|
||||||
self.send_blocks([b47], False, force_send=True, reject_reason='high-hash', reconnect=True)
|
self.send_blocks([b47], False, force_send=True, reject_reason='high-hash', reconnect=True)
|
||||||
|
|
||||||
self.log.info("Reject a block with a timestamp >2 hours in the future")
|
self.log.info("Reject a block with a timestamp >2 hours in the future")
|
||||||
self.move_tip(44)
|
self.move_tip(44)
|
||||||
b48 = self.next_block(48, solve=False)
|
b48 = self.next_block(48)
|
||||||
b48.nTime = int(self.mocktime) + 60 * 60 * 3
|
b48.nTime = int(self.mocktime) + 60 * 60 * 3
|
||||||
|
# Header timestamp has changed. Re-solve the block.
|
||||||
b48.solve()
|
b48.solve()
|
||||||
self.send_blocks([b48], False, force_send=True, reject_reason='time-too-new')
|
self.send_blocks([b48], False, force_send=True, reject_reason='time-too-new')
|
||||||
|
|
||||||
@ -1322,7 +1324,7 @@ class FullBlockTest(BitcoinTestFramework):
|
|||||||
tx.rehash()
|
tx.rehash()
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), solve=True, *, version=1):
|
def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), *, version=1):
|
||||||
if self.tip is None:
|
if self.tip is None:
|
||||||
base_block_hash = self.genesis_hash
|
base_block_hash = self.genesis_hash
|
||||||
block_time = self.mocktime + 1
|
block_time = self.mocktime + 1
|
||||||
@ -1344,10 +1346,8 @@ class FullBlockTest(BitcoinTestFramework):
|
|||||||
self.sign_tx(tx, spend)
|
self.sign_tx(tx, spend)
|
||||||
self.add_transactions_to_block(block, [tx])
|
self.add_transactions_to_block(block, [tx])
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
block.hashMerkleRoot = block.calc_merkle_root()
|
||||||
if solve:
|
# Block is created. Find a valid nonce.
|
||||||
block.solve()
|
block.solve()
|
||||||
else:
|
|
||||||
block.rehash()
|
|
||||||
self.tip = block
|
self.tip = block
|
||||||
self.block_heights[block.sha256] = height
|
self.block_heights[block.sha256] = height
|
||||||
assert number not in self.blocks
|
assert number not in self.blocks
|
||||||
|
@ -96,7 +96,20 @@ def split_inputs(from_node, txins, txouts, initial_split=False):
|
|||||||
txouts.append({"txid": txid, "vout": 0, "amount": half_change})
|
txouts.append({"txid": txid, "vout": 0, "amount": half_change})
|
||||||
txouts.append({"txid": txid, "vout": 1, "amount": rem_change})
|
txouts.append({"txid": txid, "vout": 1, "amount": rem_change})
|
||||||
|
|
||||||
def check_estimates(node, fees_seen):
|
def check_raw_estimates(node, fees_seen):
|
||||||
|
"""Call estimaterawfee and verify that the estimates meet certain invariants."""
|
||||||
|
|
||||||
|
delta = 1.0e-6 # account for rounding error
|
||||||
|
for i in range(1, 26):
|
||||||
|
for _, e in node.estimaterawfee(i).items():
|
||||||
|
feerate = float(e["feerate"])
|
||||||
|
assert_greater_than(feerate, 0)
|
||||||
|
|
||||||
|
if feerate + delta < min(fees_seen) or feerate - delta > max(fees_seen):
|
||||||
|
raise AssertionError("Estimated fee (%f) out of range (%f,%f)"
|
||||||
|
% (feerate, min(fees_seen), max(fees_seen)))
|
||||||
|
|
||||||
|
def check_smart_estimates(node, fees_seen):
|
||||||
"""Call estimatesmartfee and verify that the estimates meet certain invariants."""
|
"""Call estimatesmartfee and verify that the estimates meet certain invariants."""
|
||||||
|
|
||||||
delta = 1.0e-6 # account for rounding error
|
delta = 1.0e-6 # account for rounding error
|
||||||
@ -119,6 +132,9 @@ def check_estimates(node, fees_seen):
|
|||||||
else:
|
else:
|
||||||
assert_greater_than_or_equal(i + 1, e["blocks"])
|
assert_greater_than_or_equal(i + 1, e["blocks"])
|
||||||
|
|
||||||
|
def check_estimates(node, fees_seen):
|
||||||
|
check_raw_estimates(node, fees_seen)
|
||||||
|
check_smart_estimates(node, fees_seen)
|
||||||
|
|
||||||
class EstimateFeeTest(BitcoinTestFramework):
|
class EstimateFeeTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
|
51
test/functional/rpc_estimatefee.py
Executable file
51
test/functional/rpc_estimatefee.py
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# 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.
|
||||||
|
"""Test the estimatefee RPCs.
|
||||||
|
|
||||||
|
Test the following RPCs:
|
||||||
|
- estimatesmartfee
|
||||||
|
- estimaterawfee
|
||||||
|
"""
|
||||||
|
|
||||||
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
from test_framework.util import assert_raises_rpc_error
|
||||||
|
|
||||||
|
class EstimateFeeTest(BitcoinTestFramework):
|
||||||
|
def set_test_params(self):
|
||||||
|
self.setup_clean_chain = False
|
||||||
|
self.num_nodes = 1
|
||||||
|
|
||||||
|
def run_test(self):
|
||||||
|
# missing required params
|
||||||
|
assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee)
|
||||||
|
assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee)
|
||||||
|
|
||||||
|
# wrong type for conf_target
|
||||||
|
assert_raises_rpc_error(-3, "Expected type number, got string", self.nodes[0].estimatesmartfee, 'foo')
|
||||||
|
assert_raises_rpc_error(-3, "Expected type number, got string", self.nodes[0].estimaterawfee, 'foo')
|
||||||
|
|
||||||
|
# wrong type for estimatesmartfee(estimate_mode)
|
||||||
|
assert_raises_rpc_error(-3, "Expected type string, got number", self.nodes[0].estimatesmartfee, 1, 1)
|
||||||
|
assert_raises_rpc_error(-8, "Invalid estimate_mode parameter", self.nodes[0].estimatesmartfee, 1, 'foo')
|
||||||
|
|
||||||
|
# wrong type for estimaterawfee(threshold)
|
||||||
|
assert_raises_rpc_error(-3, "Expected type number, got string", self.nodes[0].estimaterawfee, 1, 'foo')
|
||||||
|
|
||||||
|
# extra params
|
||||||
|
assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', 1)
|
||||||
|
assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee, 1, 1, 1)
|
||||||
|
|
||||||
|
# valid calls
|
||||||
|
self.nodes[0].estimatesmartfee(1)
|
||||||
|
# self.nodes[0].estimatesmartfee(1, None)
|
||||||
|
self.nodes[0].estimatesmartfee(1, 'ECONOMICAL')
|
||||||
|
|
||||||
|
self.nodes[0].estimaterawfee(1)
|
||||||
|
self.nodes[0].estimaterawfee(1, None)
|
||||||
|
self.nodes[0].estimaterawfee(1, 1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
EstimateFeeTest().main()
|
@ -228,6 +228,7 @@ BASE_SCRIPTS = [
|
|||||||
'wallet_fallbackfee.py',
|
'wallet_fallbackfee.py',
|
||||||
'rpc_dumptxoutset.py',
|
'rpc_dumptxoutset.py',
|
||||||
'feature_minchainwork.py',
|
'feature_minchainwork.py',
|
||||||
|
'rpc_estimatefee.py',
|
||||||
'p2p_unrequested_blocks.py', # NOTE: needs dash_hash to pass
|
'p2p_unrequested_blocks.py', # NOTE: needs dash_hash to pass
|
||||||
'feature_shutdown.py',
|
'feature_shutdown.py',
|
||||||
'rpc_coinjoin.py',
|
'rpc_coinjoin.py',
|
||||||
|
@ -99,7 +99,7 @@ class CreateWalletTest(BitcoinTestFramework):
|
|||||||
self.nodes[0].createwallet(wallet_name='wblank', disable_private_keys=False, blank=True, passphrase='thisisapassphrase')
|
self.nodes[0].createwallet(wallet_name='wblank', disable_private_keys=False, blank=True, passphrase='thisisapassphrase')
|
||||||
wblank = node.get_wallet_rpc('wblank')
|
wblank = node.get_wallet_rpc('wblank')
|
||||||
assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", wblank.signmessage, "needanargument", "test")
|
assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", wblank.signmessage, "needanargument", "test")
|
||||||
wblank.walletpassphrase('thisisapassphrase', 10)
|
wblank.walletpassphrase('thisisapassphrase', 60)
|
||||||
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", wblank.getnewaddress)
|
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", wblank.getnewaddress)
|
||||||
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", wblank.getrawchangeaddress)
|
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", wblank.getrawchangeaddress)
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class CreateWalletTest(BitcoinTestFramework):
|
|||||||
self.nodes[0].createwallet(wallet_name='w6', disable_private_keys=False, blank=False, passphrase='thisisapassphrase')
|
self.nodes[0].createwallet(wallet_name='w6', disable_private_keys=False, blank=False, passphrase='thisisapassphrase')
|
||||||
w6 = node.get_wallet_rpc('w6')
|
w6 = node.get_wallet_rpc('w6')
|
||||||
assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", w6.signmessage, "needanargument", "test")
|
assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", w6.signmessage, "needanargument", "test")
|
||||||
w6.walletpassphrase('thisisapassphrase', 10)
|
w6.walletpassphrase('thisisapassphrase', 60)
|
||||||
w6.signmessage(w6.getnewaddress(), "test")
|
w6.signmessage(w6.getnewaddress(), "test")
|
||||||
w6.keypoolrefill(1)
|
w6.keypoolrefill(1)
|
||||||
# There should only be 1 key
|
# There should only be 1 key
|
||||||
@ -121,13 +121,13 @@ class CreateWalletTest(BitcoinTestFramework):
|
|||||||
resp = self.nodes[0].createwallet(wallet_name='w7', disable_private_keys=False, blank=False, passphrase='')
|
resp = self.nodes[0].createwallet(wallet_name='w7', disable_private_keys=False, blank=False, passphrase='')
|
||||||
assert_equal(resp['warning'], 'Empty string given as passphrase, wallet will not be encrypted.')
|
assert_equal(resp['warning'], 'Empty string given as passphrase, wallet will not be encrypted.')
|
||||||
w7 = node.get_wallet_rpc('w7')
|
w7 = node.get_wallet_rpc('w7')
|
||||||
assert_raises_rpc_error(-15, 'Error: running with an unencrypted wallet, but walletpassphrase was called.', w7.walletpassphrase, '', 10)
|
assert_raises_rpc_error(-15, 'Error: running with an unencrypted wallet, but walletpassphrase was called.', w7.walletpassphrase, '', 60)
|
||||||
|
|
||||||
# TODO: renable this when avoid reuse flag is added
|
# TODO: renable this when avoid reuse flag is added
|
||||||
# self.log.info('Test making a wallet with avoid reuse flag')
|
# self.log.info('Test making a wallet with avoid reuse flag')
|
||||||
# self.nodes[0].createwallet('w8', False, False, '', True) # Use positional arguments to check for bug where avoid_reuse could not be set for wallets without needing them to be encrypted
|
# self.nodes[0].createwallet('w8', False, False, '', True) # Use positional arguments to check for bug where avoid_reuse could not be set for wallets without needing them to be encrypted
|
||||||
# w8 = node.get_wallet_rpc('w8')
|
# w8 = node.get_wallet_rpc('w8')
|
||||||
# assert_raises_rpc_error(-15, 'Error: running with an unencrypted wallet, but walletpassphrase was called.', w7.walletpassphrase, '', 10)
|
# assert_raises_rpc_error(-15, 'Error: running with an unencrypted wallet, but walletpassphrase was called.', w7.walletpassphrase, '', 60)
|
||||||
# assert_equal(w8.getwalletinfo()["avoid_reuse"], True)
|
# assert_equal(w8.getwalletinfo()["avoid_reuse"], True)
|
||||||
|
|
||||||
self.log.info('Using a passphrase with private keys disabled returns error')
|
self.log.info('Using a passphrase with private keys disabled returns error')
|
||||||
|
Loading…
Reference in New Issue
Block a user