Dash Core  0.12.2.1
P2P Digital Currency
test_framework.util Namespace Reference

Functions

def enable_mocktime ()
 
def disable_mocktime ()
 
def get_mocktime ()
 
def enable_coverage (dirname)
 
def get_rpc_proxy (url, node_number, timeout=None)
 
def get_mnsync_status (node)
 
def wait_to_sync (node)
 
def p2p_port (n)
 
def rpc_port (n)
 
def check_json_precision ()
 
def count_bytes (hex_string)
 
def bytes_to_hex_str (byte_str)
 
def hex_str_to_bytes (hex_str)
 
def str_to_b64str (string)
 
def sync_blocks (rpc_connections, wait=1)
 
def sync_mempools (rpc_connections, wait=1)
 
def sync_masternodes (rpc_connections)
 
def initialize_datadir (dirname, n)
 
def rpc_url (i, rpchost=None)
 
def wait_for_bitcoind_start (process, url, i)
 
def initialize_chain (test_dir)
 
def initialize_chain_clean (test_dir, num_nodes)
 
def _rpchost_to_args (rpchost)
 
def start_node (i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
 
def start_nodes (num_nodes, dirname, extra_args=None, rpchost=None, binary=None)
 
def log_filename (dirname, n_node, logname)
 
def stop_node (node, i)
 
def stop_nodes (nodes)
 
def set_node_times (nodes, t)
 
def wait_bitcoinds ()
 
def connect_nodes (from_connection, node_num)
 
def connect_nodes_bi (nodes, a, b)
 
def find_output (node, txid, amount)
 
def gather_inputs (from_node, amount_needed, confirmations_required=1)
 
def make_change (from_node, amount_in, amount_out, fee)
 
def send_zeropri_transaction (from_node, to_node, amount, fee)
 
def random_zeropri_transaction (nodes, amount, min_fee, fee_increment, fee_variants)
 
def random_transaction (nodes, amount, min_fee, fee_increment, fee_variants)
 
def assert_equal (thing1, thing2)
 
def assert_greater_than (thing1, thing2)
 
def assert_raises (exc, fun, args, kwds)
 
def assert_is_hex_string (string)
 
def assert_is_hash_string (string, length=64)
 
def assert_array_result (object_array, to_match, expected, should_not_find=False)
 
def satoshi_round (amount)
 
def create_confirmed_utxos (fee, node, count)
 
def gen_return_txouts ()
 
def create_tx (node, coinbase, to_address, amount)
 
def create_lots_of_big_transactions (node, txouts, utxos, fee)
 
def get_bip9_status (node, key)
 

Variables

 COVERAGE_DIR = None
 
int MOCKTIME = 0
 
dictionary bitcoind_processes = {}
 

Function Documentation

◆ _rpchost_to_args()

def test_framework.util._rpchost_to_args (   rpchost)
private
Convert optional IP:port spec to rpcconnect/rpcport args

Definition at line 261 of file util.py.

◆ assert_array_result()

def test_framework.util.assert_array_result (   object_array,
  to_match,
  expected,
  should_not_find = False 
)
    Pass in array of JSON objects, a dictionary with key/value pairs
    to match against, and another dictionary with expected key/value
    pairs.
    If the should_not_find flag is true, to_match should not be found
    in object_array

Definition at line 496 of file util.py.

Referenced by listtransactions.ListTransactionsTest.run_rbf_opt_in_test(), listtransactions.ListTransactionsTest.run_test(), receivedby.ReceivedByTest.run_test(), and wallet.WalletTest.run_test().

◆ assert_equal()

def test_framework.util.assert_equal (   thing1,
  thing2 
)

Definition at line 461 of file util.py.

Referenced by blockchain.BlockchainTest._test_getblockheader(), blockchain.BlockchainTest._test_gettxoutsetinfo(), test_framework.util.assert_array_result(), smartfees.check_estimates(), test_framework.util.create_tx(), decodescript.DecodeScriptTest.decoderawtransaction_asm_sighashtype(), decodescript.DecodeScriptTest.decodescript_script_pub_key(), decodescript.DecodeScriptTest.decodescript_script_sig(), proxy_test.ProxyTest.node_test(), reindex.ReindexTest.reindex(), rpcbind_test.run_bind_test(), listtransactions.ListTransactionsTest.run_rbf_opt_in_test(), keypool-hd.KeyPoolTest.run_test(), keypool.KeyPoolTest.run_test(), txn_clone.TxnMallTest.run_test(), nodehandling.NodeHandlingTest.run_test(), txn_doublespend.TxnMallTest.run_test(), mempool_resurrect_test.MempoolCoinbaseTest.run_test(), zapwallettxes.ZapWalletTXesTest.run_test(), wallet-hd.WalletHDTest.run_test(), httpbasics.HTTPBasicsTest.run_test(), fundrawtransaction-hd.RawTransactionsTest.run_test(), fundrawtransaction.RawTransactionsTest.run_test(), mempool_reorg.MempoolCoinbaseTest.run_test(), mempool_spendcoinbase.MempoolSpendCoinbaseTest.run_test(), prioritise_transaction.PrioritiseTransactionTest.run_test(), merkle_blocks.MerkleBlockTest.run_test(), test_framework.test_framework.BitcoinTestFramework.run_test(), wallet.WalletTest.run_test(), multi_rpc.HTTPBasicsTest.run_test(), rawtransactions.RawTransactionsTest.run_test(), timestampindex.TimestampIndexTest.run_test(), txindex.TxIndexTest.run_test(), spentindex.SpentIndexTest.run_test(), addressindex.AddressIndexTest.run_test(), mempool_packages.MempoolPackagesTest.run_test(), zmq_test.ZMQTest.run_test(), rest.RESTTest.run_test(), walletbackup.WalletBackupTest.run_test(), maxuploadtarget.MaxUploadTest.run_test(), p2p-acceptblock.AcceptBlockTest.run_test(), proxy_test.ProxyTest.run_test(), signrawtransactions.SignRawTransactionsTest.script_verification_error_test(), signrawtransactions.SignRawTransactionsTest.successful_signing_test(), bip68-sequence.BIP68Test.test_bip68_not_consensus(), bip68-sequence.BIP68Test.test_disable_flag(), replace-by-fee.ReplaceByFeeTest.test_doublespend_chain(), replace-by-fee.ReplaceByFeeTest.test_doublespend_tree(), replace-by-fee.ReplaceByFeeTest.test_new_unconfirmed_inputs(), replace-by-fee.ReplaceByFeeTest.test_opt_in(), replace-by-fee.ReplaceByFeeTest.test_prioritised_transactions(), replace-by-fee.ReplaceByFeeTest.test_replacement_feeperkb(), bip68-sequence.BIP68Test.test_sequence_lock_confirmed_inputs(), bip68-sequence.BIP68Test.test_sequence_lock_unconfirmed_inputs(), replace-by-fee.ReplaceByFeeTest.test_simple_doublespend(), replace-by-fee.ReplaceByFeeTest.test_spends_of_conflicting_outputs(), and replace-by-fee.ReplaceByFeeTest.test_too_many_replacements().

◆ assert_greater_than()

def test_framework.util.assert_greater_than (   thing1,
  thing2 
)

◆ assert_is_hash_string()

def test_framework.util.assert_is_hash_string (   string,
  length = 64 
)

Definition at line 486 of file util.py.

Referenced by blockchain.BlockchainTest._test_getblockheader().

◆ assert_is_hex_string()

def test_framework.util.assert_is_hex_string (   string)

Definition at line 479 of file util.py.

Referenced by blockchain.BlockchainTest._test_getblockheader().

◆ assert_raises()

◆ bytes_to_hex_str()

◆ check_json_precision()

def test_framework.util.check_json_precision ( )
Make sure json library being used does not lose precision converting BTC values

Definition at line 98 of file util.py.

◆ connect_nodes()

◆ connect_nodes_bi()

◆ count_bytes()

def test_framework.util.count_bytes (   hex_string)

Definition at line 105 of file util.py.

Referenced by wallet.WalletTest.run_test().

◆ create_confirmed_utxos()

def test_framework.util.create_confirmed_utxos (   fee,
  node,
  count 
)

◆ create_lots_of_big_transactions()

def test_framework.util.create_lots_of_big_transactions (   node,
  txouts,
  utxos,
  fee 
)

◆ create_tx()

def test_framework.util.create_tx (   node,
  coinbase,
  to_address,
  amount 
)

Definition at line 577 of file util.py.

◆ disable_mocktime()

def test_framework.util.disable_mocktime ( )

Definition at line 45 of file util.py.

Referenced by test_framework.util.initialize_chain().

◆ enable_coverage()

def test_framework.util.enable_coverage (   dirname)
Maintain a log of which RPC calls are made during testing.

Definition at line 52 of file util.py.

Referenced by test_framework.test_framework.BitcoinTestFramework.main().

◆ enable_mocktime()

def test_framework.util.enable_mocktime ( )

◆ find_output()

def test_framework.util.find_output (   node,
  txid,
  amount 
)
Return index to output of txid with value amount
Raises exception if there is none.

Definition at line 355 of file util.py.

Referenced by txn_doublespend.TxnMallTest.run_test(), and test_framework.util.send_zeropri_transaction().

◆ gather_inputs()

def test_framework.util.gather_inputs (   from_node,
  amount_needed,
  confirmations_required = 1 
)
Return a random set of unspent txouts that are enough to pay amount_needed

Definition at line 367 of file util.py.

Referenced by test_framework.util.random_transaction(), and test_framework.util.send_zeropri_transaction().

◆ gen_return_txouts()

def test_framework.util.gen_return_txouts ( )

Definition at line 559 of file util.py.

◆ get_bip9_status()

def test_framework.util.get_bip9_status (   node,
  key 
)

◆ get_mnsync_status()

def test_framework.util.get_mnsync_status (   node)

Definition at line 83 of file util.py.

Referenced by test_framework.util.wait_to_sync().

◆ get_mocktime()

def test_framework.util.get_mocktime ( )

Definition at line 49 of file util.py.

Referenced by test_framework.util.initialize_chain(), and test_framework.util.start_node().

◆ get_rpc_proxy()

def test_framework.util.get_rpc_proxy (   url,
  node_number,
  timeout = None 
)
Args:
    url (str): URL of the RPC server to call
    node_number (int): the node number (or id) that this calls to

Kwargs:
    timeout (int): HTTP timeout in seconds

Returns:
    AuthServiceProxy. convenience object for making RPC calls.

Definition at line 58 of file util.py.

Referenced by test_framework.util.initialize_chain(), rpcbind_test.run_allowip_test(), test_framework.util.start_node(), and test_framework.util.wait_for_bitcoind_start().

◆ hex_str_to_bytes()

◆ initialize_chain()

def test_framework.util.initialize_chain (   test_dir)
Create (or copy from cache) a 200-block-long chain and
4 wallets.

Definition at line 184 of file util.py.

Referenced by rpcbind_test.main(), multi_rpc.HTTPBasicsTest.setup_chain(), and blockchain.BlockchainTest.setup_chain().

◆ initialize_chain_clean()

def test_framework.util.initialize_chain_clean (   test_dir,
  num_nodes 
)
Create an empty blockchain and num_nodes wallets.
Useful if a test case wants complete control over initialization.

Definition at line 252 of file util.py.

Referenced by fundrawtransaction-hd.RawTransactionsTest.setup_chain(), fundrawtransaction.RawTransactionsTest.setup_chain(), zapwallettxes.ZapWalletTXesTest.setup_chain(), signrawtransactions.SignRawTransactionsTest.setup_chain(), decodescript.DecodeScriptTest.setup_chain(), wallet-hd.WalletHDTest.setup_chain(), reindex.ReindexTest.setup_chain(), merkle_blocks.MerkleBlockTest.setup_chain(), invalidateblock.InvalidateTest.setup_chain(), disablewallet.DisableWalletTest.setup_chain(), rawtransactions.RawTransactionsTest.setup_chain(), timestampindex.TimestampIndexTest.setup_chain(), txindex.TxIndexTest.setup_chain(), addressindex.AddressIndexTest.setup_chain(), spentindex.SpentIndexTest.setup_chain(), prioritise_transaction.PrioritiseTransactionTest.setup_chain(), mempool_limit.MempoolLimitTest.setup_chain(), wallet.WalletTest.setup_chain(), pruning.PruneTest.setup_chain(), walletbackup.WalletBackupTest.setup_chain(), rest.RESTTest.setup_chain(), p2p-versionbits-warning.VersionBitsWarningTest.setup_chain(), keypool.KeyPoolTest.setup_chain(), maxblocksinflight.MaxBlocksInFlightTest.setup_chain(), maxuploadtarget.MaxUploadTest.setup_chain(), keypool-hd.KeyPoolTest.setup_chain(), p2p-acceptblock.AcceptBlockTest.setup_chain(), test_framework.test_framework.ComparisonTestFramework.setup_chain(), and sendheaders.SendHeadersTest.setup_chain().

◆ initialize_datadir()

def test_framework.util.initialize_datadir (   dirname,
  n 
)

◆ log_filename()

def test_framework.util.log_filename (   dirname,
  n_node,
  logname 
)

Definition at line 320 of file util.py.

Referenced by test_framework.util.initialize_chain().

◆ make_change()

def test_framework.util.make_change (   from_node,
  amount_in,
  amount_out,
  fee 
)
Create change output(s), return them

Definition at line 384 of file util.py.

Referenced by test_framework.util.random_transaction(), and test_framework.util.send_zeropri_transaction().

◆ p2p_port()

◆ random_transaction()

def test_framework.util.random_transaction (   nodes,
  amount,
  min_fee,
  fee_increment,
  fee_variants 
)
Create a random transaction.
Returns (txid, hex-encoded-transaction-data, fee)

Definition at line 442 of file util.py.

Referenced by getblocktemplate_longpoll.GetBlockTemplateLPTest.run_test().

◆ random_zeropri_transaction()

def test_framework.util.random_zeropri_transaction (   nodes,
  amount,
  min_fee,
  fee_increment,
  fee_variants 
)
Create a random zero-priority transaction.
Returns (txid, hex-encoded-transaction-data, fee)

Definition at line 431 of file util.py.

◆ rpc_port()

def test_framework.util.rpc_port (   n)

◆ rpc_url()

def test_framework.util.rpc_url (   i,
  rpchost = None 
)

◆ satoshi_round()

◆ send_zeropri_transaction()

def test_framework.util.send_zeropri_transaction (   from_node,
  to_node,
  amount,
  fee 
)
Create&broadcast a zero-priority transaction.
Returns (txid, hex-encoded-txdata)
Ensures transaction is zero-priority by first creating a send-to-self,
then using its output

Definition at line 401 of file util.py.

Referenced by test_framework.util.random_zeropri_transaction().

◆ set_node_times()

def test_framework.util.set_node_times (   nodes,
  t 
)

Definition at line 333 of file util.py.

Referenced by test_framework.util.initialize_chain().

◆ start_node()

◆ start_nodes()

◆ stop_node()

◆ stop_nodes()

◆ str_to_b64str()

def test_framework.util.str_to_b64str (   string)

◆ sync_blocks()

◆ sync_masternodes()

def test_framework.util.sync_masternodes (   rpc_connections)

Definition at line 142 of file util.py.

Referenced by p2p-fullblocktest.FullBlockTest.run_test().

◆ sync_mempools()

◆ wait_bitcoinds()

◆ wait_for_bitcoind_start()

def test_framework.util.wait_for_bitcoind_start (   process,
  url,
  i 
)
Wait for dashd to start. This means that RPC is accessible and fully initialized.
Raise an exception if dashd exits during initialization.

Definition at line 164 of file util.py.

Referenced by test_framework.util.initialize_chain(), and test_framework.util.start_node().

◆ wait_to_sync()

Variable Documentation

◆ bitcoind_processes

dictionary test_framework.util.bitcoind_processes = {}

Definition at line 146 of file util.py.

◆ COVERAGE_DIR

test_framework.util.COVERAGE_DIR = None

Definition at line 29 of file util.py.

◆ MOCKTIME

int test_framework.util.MOCKTIME = 0

Definition at line 36 of file util.py.