mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
161 lines
132 KiB
HTML
161 lines
132 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.14"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Dash Core: qa/rpc-tests/test_framework/util.py Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(initResizable);
|
|
/* @license-end */</script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="bitcoin_logo_doxygen.png"/></td>
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">Dash Core
|
|
 <span id="projectnumber">0.12.2.1</span>
|
|
</div>
|
|
<div id="projectbrief">P2P Digital Currency</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function(){initNavTree('util_8py_source.html','');});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">util.py</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="util_8py.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html"> 1</a></span> <span class="comment"># Copyright (c) 2014-2015 The Bitcoin Core developers</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"># Copyright (c) 2014-2017 The Dash Core developers</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"># Distributed under the MIT/X11 software license, see the accompanying</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"># file COPYING or http://www.opensource.org/licenses/mit-license.php.</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> </div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> </div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">#</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"># Helpful routines for regression testing</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">#</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> </div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"># Add python-bitcoinrpc to module search path:</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="keyword">import</span> os</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="keyword">import</span> sys</div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> </div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="keyword">from</span> binascii <span class="keyword">import</span> hexlify, unhexlify</div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="keyword">from</span> base64 <span class="keyword">import</span> b64encode</div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="keyword">from</span> decimal <span class="keyword">import</span> Decimal, ROUND_DOWN</div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="keyword">import</span> json</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="keyword">import</span> random</div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="keyword">import</span> shutil</div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="keyword">import</span> subprocess</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="keyword">import</span> time</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="keyword">import</span> re</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="keyword">import</span> errno</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> </div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="keyword">from</span> . <span class="keyword">import</span> coverage</div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="keyword">from</span> .authproxy <span class="keyword">import</span> AuthServiceProxy, JSONRPCException</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> </div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#acc7d516af3446794517b2a1a9927b50c"> 29</a></span> COVERAGE_DIR = <span class="keywordtype">None</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="comment">#Set Mocktime default to OFF.</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="comment">#MOCKTIME is only needed for scripts that use the</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="comment">#cached version of the blockchain. If the cached</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="comment">#version of the blockchain is used without MOCKTIME</span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="comment">#then the mempools will not sync due to IBD.</span></div><div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#afcb105ca19ee0438c1fbe12a8b3b99bb"> 36</a></span> MOCKTIME = 0</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> </div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#af641a75ac322987542583d7b2222c25a"> 38</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#af641a75ac322987542583d7b2222c25a">enable_mocktime</a>():</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="comment">#For backwared compatibility of the python scripts</span></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="comment">#with previous versions of the cache, set MOCKTIME </span></div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="comment">#to regtest genesis time + (201 * 156)</span></div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keyword">global</span> MOCKTIME</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  MOCKTIME = 1417713337 + (201 * 156)</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> </div><div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a43f0c78d2371ed5dd82720572493fc09"> 45</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a43f0c78d2371ed5dd82720572493fc09">disable_mocktime</a>():</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="keyword">global</span> MOCKTIME</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  MOCKTIME = 0</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div><div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a4176bf733648642a46bbc3e14438f441"> 49</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a4176bf733648642a46bbc3e14438f441">get_mocktime</a>():</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keywordflow">return</span> MOCKTIME</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span> </div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ae9c2671db3d700ac6920b8ee10dcbce1"> 52</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ae9c2671db3d700ac6920b8ee10dcbce1">enable_coverage</a>(dirname):</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="stringliteral">"""Maintain a log of which RPC calls are made during testing."""</span></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keyword">global</span> COVERAGE_DIR</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  COVERAGE_DIR = dirname</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span> </div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span> </div><div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#adf11fca732419a7289c9d119119b34f2"> 58</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#adf11fca732419a7289c9d119119b34f2">get_rpc_proxy</a>(url, node_number, timeout=None):</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="stringliteral"> Args:</span></div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="stringliteral"> url (str): URL of the RPC server to call</span></div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="stringliteral"> node_number (int): the node number (or id) that this calls to</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="stringliteral"></span></div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="stringliteral"> Kwargs:</span></div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="stringliteral"> timeout (int): HTTP timeout in seconds</span></div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="stringliteral"></span></div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="stringliteral"> Returns:</span></div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="stringliteral"> AuthServiceProxy. convenience object for making RPC calls.</span></div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> <span class="stringliteral"></span></div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  proxy_kwargs = {}</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="keywordflow">if</span> timeout <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  proxy_kwargs[<span class="stringliteral">'timeout'</span>] = timeout</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  proxy = <a class="code" href="classtest__framework_1_1authproxy_1_1AuthServiceProxy.html">AuthServiceProxy</a>(url, **proxy_kwargs)</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  proxy.url = url <span class="comment"># store URL on proxy for info</span></div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> </div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  coverage_logfile = coverage.get_filename(</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  COVERAGE_DIR, node_number) <span class="keywordflow">if</span> COVERAGE_DIR <span class="keywordflow">else</span> <span class="keywordtype">None</span></div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span> </div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <span class="keywordflow">return</span> <a class="code" href="classtest__framework_1_1coverage_1_1AuthServiceProxyWrapper.html">coverage.AuthServiceProxyWrapper</a>(proxy, coverage_logfile)</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span> </div><div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ad6740628a03c98f11b891be7f27741df"> 83</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ad6740628a03c98f11b891be7f27741df">get_mnsync_status</a>(node):</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  result = node.mnsync(<span class="stringliteral">"status"</span>)</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="keywordflow">return</span> result[<span class="stringliteral">'IsSynced'</span>]</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span> </div><div class="line"><a name="l00087"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a6cfe71893f4a2ba2e7f30d87c615a322"> 87</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a6cfe71893f4a2ba2e7f30d87c615a322">wait_to_sync</a>(node):</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  synced = <span class="keyword">False</span></div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  <span class="keywordflow">while</span> <span class="keywordflow">not</span> synced:</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  synced = <a class="code" href="namespacetest__framework_1_1util.html#ad6740628a03c98f11b891be7f27741df">get_mnsync_status</a>(node)</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  time.sleep(0.5)</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span> </div><div class="line"><a name="l00093"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86"> 93</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">p2p_port</a>(n):</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <span class="keywordflow">return</span> 11000 + n + os.getpid()%999</div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#add85a25262bdd7a65a811c3084600158"> 95</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#add85a25262bdd7a65a811c3084600158">rpc_port</a>(n):</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <span class="keywordflow">return</span> 12000 + n + os.getpid()%999</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span> </div><div class="line"><a name="l00098"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a014ebe32f938d2f22cc54592a9eaffca"> 98</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a014ebe32f938d2f22cc54592a9eaffca">check_json_precision</a>():</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  <span class="stringliteral">"""Make sure json library being used does not lose precision converting BTC values"""</span></div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  n = Decimal(<span class="stringliteral">"20000000.00000003"</span>)</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  satoshis = int(json.loads(json.dumps(float(n)))*1.0e8)</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="keywordflow">if</span> satoshis != 2000000000000003:</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordflow">raise</span> RuntimeError(<span class="stringliteral">"JSON encode/decode loses precision"</span>)</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span> </div><div class="line"><a name="l00105"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a3e374173222041b2ca3ec9b06993d62f"> 105</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a3e374173222041b2ca3ec9b06993d62f">count_bytes</a>(hex_string):</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  <span class="keywordflow">return</span> len(bytearray.fromhex(hex_string))</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span> </div><div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ae6b425a1e3feb505726ee64525523264"> 108</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ae6b425a1e3feb505726ee64525523264">bytes_to_hex_str</a>(byte_str):</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="keywordflow">return</span> hexlify(byte_str).decode(<span class="stringliteral">'ascii'</span>)</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span> </div><div class="line"><a name="l00111"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a7a98a073cd2a7a26b707f52d2fef01be"> 111</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a7a98a073cd2a7a26b707f52d2fef01be">hex_str_to_bytes</a>(hex_str):</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="keywordflow">return</span> unhexlify(hex_str.encode(<span class="stringliteral">'ascii'</span>))</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span> </div><div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#aa5bb10ad85ada1af40351b523264e1eb"> 114</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#aa5bb10ad85ada1af40351b523264e1eb">str_to_b64str</a>(string):</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <span class="keywordflow">return</span> b64encode(string.encode(<span class="stringliteral">'utf-8'</span>)).decode(<span class="stringliteral">'ascii'</span>)</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> </div><div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#aa20567f95203db19bbd3bf531ddabff6"> 117</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#aa20567f95203db19bbd3bf531ddabff6">sync_blocks</a>(rpc_connections, wait=1):</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span> <span class="stringliteral"> Wait until everybody has the same block count</span></div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keywordflow">while</span> <span class="keyword">True</span>:</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  counts = [ x.getblockcount() <span class="keywordflow">for</span> x <span class="keywordflow">in</span> rpc_connections ]</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="keywordflow">if</span> counts == [ counts[0] ]*len(counts):</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="keywordflow">break</span></div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  time.sleep(wait)</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span> </div><div class="line"><a name="l00127"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a7564b2d8364eadc29117e34d1cd00ad4"> 127</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a7564b2d8364eadc29117e34d1cd00ad4">sync_mempools</a>(rpc_connections, wait=1):</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span> <span class="stringliteral"> Wait until everybody has the same transactions in their memory</span></div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span> <span class="stringliteral"> pools</span></div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="keywordflow">while</span> <span class="keyword">True</span>:</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  pool = set(rpc_connections[0].<a class="code" href="blockchain_8cpp.html#a44f5bbe5b8c41540712ec39d2ece88a9">getrawmempool</a>())</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  num_match = 1</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(1, len(rpc_connections)):</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keywordflow">if</span> set(rpc_connections[i].<a class="code" href="blockchain_8cpp.html#a44f5bbe5b8c41540712ec39d2ece88a9">getrawmempool</a>()) == pool:</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  num_match = num_match+1</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keywordflow">if</span> num_match == len(rpc_connections):</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordflow">break</span></div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  time.sleep(wait)</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span> </div><div class="line"><a name="l00142"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a2f920625c10176f344e857eea15e75b4"> 142</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a2f920625c10176f344e857eea15e75b4">sync_masternodes</a>(rpc_connections):</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordflow">for</span> node <span class="keywordflow">in</span> rpc_connections:</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <a class="code" href="namespacetest__framework_1_1util.html#a6cfe71893f4a2ba2e7f30d87c615a322">wait_to_sync</a>(node)</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span> </div><div class="line"><a name="l00146"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a74f4539c6d27d175fca8a87ab56d2c75"> 146</a></span> bitcoind_processes = {}</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span> </div><div class="line"><a name="l00148"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ab508713a21d5cb4d5629119aaf1e770b"> 148</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ab508713a21d5cb4d5629119aaf1e770b">initialize_datadir</a>(dirname, n):</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  datadir = os.path.join(dirname, <span class="stringliteral">"node"</span>+str(n))</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="keywordflow">if</span> <span class="keywordflow">not</span> os.path.isdir(datadir):</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  os.makedirs(datadir)</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  with open(os.path.join(datadir, <span class="stringliteral">"dash.conf"</span>), <span class="stringliteral">'w'</span>) <span class="keyword">as</span> f:</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  f.write(<span class="stringliteral">"regtest=1\n"</span>)</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  f.write(<span class="stringliteral">"rpcuser=rt\n"</span>)</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  f.write(<span class="stringliteral">"rpcpassword=rt\n"</span>)</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  f.write(<span class="stringliteral">"port="</span>+str(<a class="code" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">p2p_port</a>(n))+<span class="stringliteral">"\n"</span>)</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  f.write(<span class="stringliteral">"rpcport="</span>+str(<a class="code" href="namespacetest__framework_1_1util.html#add85a25262bdd7a65a811c3084600158">rpc_port</a>(n))+<span class="stringliteral">"\n"</span>)</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  f.write(<span class="stringliteral">"listenonion=0\n"</span>)</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <span class="keywordflow">return</span> datadir</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span> </div><div class="line"><a name="l00161"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a016b1065dcfa9d79ebdb1b56d721c3ba"> 161</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a016b1065dcfa9d79ebdb1b56d721c3ba">rpc_url</a>(i, rpchost=None):</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  <span class="keywordflow">return</span> <span class="stringliteral">"http://rt:rt@%s:%d"</span> % (rpchost <span class="keywordflow">or</span> <span class="stringliteral">'127.0.0.1'</span>, <a class="code" href="namespacetest__framework_1_1util.html#add85a25262bdd7a65a811c3084600158">rpc_port</a>(i))</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span> </div><div class="line"><a name="l00164"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a239cec5d2c7ebb76bac776573d2fe3ba"> 164</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a239cec5d2c7ebb76bac776573d2fe3ba">wait_for_bitcoind_start</a>(process, url, i):</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  <span class="stringliteral">'''</span></div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span> <span class="stringliteral"> Wait for dashd to start. This means that RPC is accessible and fully initialized.</span></div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span> <span class="stringliteral"> Raise an exception if dashd exits during initialization.</span></div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span> <span class="stringliteral"> '''</span></div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="keywordflow">while</span> <span class="keyword">True</span>:</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  <span class="keywordflow">if</span> process.poll() <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="keywordflow">raise</span> Exception(<span class="stringliteral">'dashd exited with status %i during initialization'</span> % process.returncode)</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  <span class="keywordflow">try</span>:</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  rpc = <a class="code" href="namespacetest__framework_1_1util.html#adf11fca732419a7289c9d119119b34f2">get_rpc_proxy</a>(url, i)</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  blocks = rpc.getblockcount()</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  <span class="keywordflow">break</span> <span class="comment"># break out of loop on success</span></div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="keywordflow">except</span> IOError <span class="keyword">as</span> e:</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <span class="keywordflow">if</span> e.errno != errno.ECONNREFUSED: <span class="comment"># Port not yet open?</span></div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  <span class="keywordflow">raise</span> <span class="comment"># unknown IO error</span></div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keywordflow">except</span> JSONRPCException <span class="keyword">as</span> e: <span class="comment"># Initialization phase</span></div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  <span class="keywordflow">if</span> e.error[<span class="stringliteral">'code'</span>] != -28: <span class="comment"># RPC in warmup?</span></div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  <span class="keywordflow">raise</span> <span class="comment"># unkown JSON RPC exception</span></div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  time.sleep(0.25)</div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span> </div><div class="line"><a name="l00184"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a8571fcee33420f02c7703f938ebfe545"> 184</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a8571fcee33420f02c7703f938ebfe545">initialize_chain</a>(test_dir):</div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span> <span class="stringliteral"> Create (or copy from cache) a 200-block-long chain and</span></div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span> <span class="stringliteral"> 4 wallets.</span></div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span> </div><div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  <span class="keywordflow">if</span> (<span class="keywordflow">not</span> os.path.isdir(os.path.join(<span class="stringliteral">"cache"</span>,<span class="stringliteral">"node0"</span>))</div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span>  <span class="keywordflow">or</span> <span class="keywordflow">not</span> os.path.isdir(os.path.join(<span class="stringliteral">"cache"</span>,<span class="stringliteral">"node1"</span>))</div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  <span class="keywordflow">or</span> <span class="keywordflow">not</span> os.path.isdir(os.path.join(<span class="stringliteral">"cache"</span>,<span class="stringliteral">"node2"</span>))</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span>  <span class="keywordflow">or</span> <span class="keywordflow">not</span> os.path.isdir(os.path.join(<span class="stringliteral">"cache"</span>,<span class="stringliteral">"node3"</span>))):</div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span> </div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span>  <span class="comment">#find and delete old cache directories if any exist</span></div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(4):</div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  <span class="keywordflow">if</span> os.path.isdir(os.path.join(<span class="stringliteral">"cache"</span>,<span class="stringliteral">"node"</span>+str(i))):</div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span>  shutil.rmtree(os.path.join(<span class="stringliteral">"cache"</span>,<span class="stringliteral">"node"</span>+str(i)))</div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span> </div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  <span class="comment"># Create cache directories, run dashds:</span></div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(4):</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  datadir=<a class="code" href="namespacetest__framework_1_1util.html#ab508713a21d5cb4d5629119aaf1e770b">initialize_datadir</a>(<span class="stringliteral">"cache"</span>, i)</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  args = [ os.getenv(<span class="stringliteral">"DASHD"</span>, <span class="stringliteral">"dashd"</span>), <span class="stringliteral">"-server"</span>, <span class="stringliteral">"-keypool=1"</span>, <span class="stringliteral">"-datadir="</span>+datadir, <span class="stringliteral">"-discover=0"</span> ]</div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  <span class="keywordflow">if</span> i > 0:</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  args.append(<span class="stringliteral">"-connect=127.0.0.1:"</span>+str(<a class="code" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">p2p_port</a>(0)))</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  bitcoind_processes[i] = subprocess.Popen(args)</div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  <span class="keywordflow">if</span> os.getenv(<span class="stringliteral">"PYTHON_DEBUG"</span>, <span class="stringliteral">""</span>):</div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  <span class="keywordflow">print</span> <span class="stringliteral">"initialize_chain: dashd started, waiting for RPC to come up"</span></div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  <a class="code" href="namespacetest__framework_1_1util.html#a239cec5d2c7ebb76bac776573d2fe3ba">wait_for_bitcoind_start</a>(bitcoind_processes[i], <a class="code" href="namespacetest__framework_1_1util.html#a016b1065dcfa9d79ebdb1b56d721c3ba">rpc_url</a>(i), i)</div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="keywordflow">if</span> os.getenv(<span class="stringliteral">"PYTHON_DEBUG"</span>, <span class="stringliteral">""</span>):</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <span class="keywordflow">print</span> <span class="stringliteral">"initialize_chain: RPC succesfully started"</span></div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span> </div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  rpcs = []</div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(4):</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  <span class="keywordflow">try</span>:</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  rpcs.append(<a class="code" href="namespacetest__framework_1_1util.html#adf11fca732419a7289c9d119119b34f2">get_rpc_proxy</a>(<a class="code" href="namespacetest__framework_1_1util.html#a016b1065dcfa9d79ebdb1b56d721c3ba">rpc_url</a>(i), i))</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  <span class="keywordflow">except</span>:</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  sys.stderr.write(<span class="stringliteral">"Error connecting to "</span>+url+<span class="stringliteral">"\n"</span>)</div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  sys.exit(1)</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span> </div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  <span class="comment"># Create a 200-block-long chain; each of the 4 nodes</span></div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  <span class="comment"># gets 25 mature blocks and 25 immature.</span></div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  <span class="comment"># blocks are created with timestamps 156 seconds apart</span></div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>  <span class="comment"># starting from 31356 seconds in the past</span></div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>  <a class="code" href="namespacetest__framework_1_1util.html#af641a75ac322987542583d7b2222c25a">enable_mocktime</a>()</div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>  block_time = <a class="code" href="namespacetest__framework_1_1util.html#a4176bf733648642a46bbc3e14438f441">get_mocktime</a>() - (201 * 156)</div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(2):</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  <span class="keywordflow">for</span> peer <span class="keywordflow">in</span> range(4):</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  <span class="keywordflow">for</span> j <span class="keywordflow">in</span> range(25):</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  <a class="code" href="namespacetest__framework_1_1util.html#a6750da97ae214f27a180d67ed8c7fb37">set_node_times</a>(rpcs, block_time)</div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  rpcs[peer].<a class="code" href="mining_8cpp.html#afc5f2c0cbe40a2f876b46df2929cf359">generate</a>(1)</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  block_time += 156</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  <span class="comment"># Must sync before next peer starts generating blocks</span></div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  <a class="code" href="namespacetest__framework_1_1util.html#aa20567f95203db19bbd3bf531ddabff6">sync_blocks</a>(rpcs)</div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span> </div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  <span class="comment"># Shut them down, and clean up cache directories:</span></div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span>  <a class="code" href="namespacetest__framework_1_1util.html#ab86494439dc4a3b58f808c6b9897930c">stop_nodes</a>(rpcs)</div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  <a class="code" href="namespacetest__framework_1_1util.html#a9e0ced9f6fa4bdbcfcd6e52363cfba74">wait_bitcoinds</a>()</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  <a class="code" href="namespacetest__framework_1_1util.html#a43f0c78d2371ed5dd82720572493fc09">disable_mocktime</a>()</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(4):</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  os.remove(<a class="code" href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d">log_filename</a>(<span class="stringliteral">"cache"</span>, i, <span class="stringliteral">"debug.log"</span>))</div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  os.remove(<a class="code" href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d">log_filename</a>(<span class="stringliteral">"cache"</span>, i, <span class="stringliteral">"db.log"</span>))</div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span>  os.remove(<a class="code" href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d">log_filename</a>(<span class="stringliteral">"cache"</span>, i, <span class="stringliteral">"peers.dat"</span>))</div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  os.remove(<a class="code" href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d">log_filename</a>(<span class="stringliteral">"cache"</span>, i, <span class="stringliteral">"fee_estimates.dat"</span>))</div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span> </div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(4):</div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span>  from_dir = os.path.join(<span class="stringliteral">"cache"</span>, <span class="stringliteral">"node"</span>+str(i))</div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span>  to_dir = os.path.join(test_dir, <span class="stringliteral">"node"</span>+str(i))</div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span>  shutil.copytree(from_dir, to_dir)</div><div class="line"><a name="l00250"></a><span class="lineno"> 250</span>  <a class="code" href="namespacetest__framework_1_1util.html#ab508713a21d5cb4d5629119aaf1e770b">initialize_datadir</a>(test_dir, i) <span class="comment"># Overwrite port/rpcport in dash.conf</span></div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span> </div><div class="line"><a name="l00252"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a0d5c2187844d0b046113dbea6b956413"> 252</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a0d5c2187844d0b046113dbea6b956413">initialize_chain_clean</a>(test_dir, num_nodes):</div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00254"></a><span class="lineno"> 254</span> <span class="stringliteral"> Create an empty blockchain and num_nodes wallets.</span></div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span> <span class="stringliteral"> Useful if a test case wants complete control over initialization.</span></div><div class="line"><a name="l00256"></a><span class="lineno"> 256</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00257"></a><span class="lineno"> 257</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(num_nodes):</div><div class="line"><a name="l00258"></a><span class="lineno"> 258</span>  datadir=<a class="code" href="namespacetest__framework_1_1util.html#ab508713a21d5cb4d5629119aaf1e770b">initialize_datadir</a>(test_dir, i)</div><div class="line"><a name="l00259"></a><span class="lineno"> 259</span> </div><div class="line"><a name="l00260"></a><span class="lineno"> 260</span> </div><div class="line"><a name="l00261"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a42d666cfdf0d62c3e36ba4d9f4026621"> 261</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a42d666cfdf0d62c3e36ba4d9f4026621">_rpchost_to_args</a>(rpchost):</div><div class="line"><a name="l00262"></a><span class="lineno"> 262</span>  <span class="stringliteral">'''Convert optional IP:port spec to rpcconnect/rpcport args'''</span></div><div class="line"><a name="l00263"></a><span class="lineno"> 263</span>  <span class="keywordflow">if</span> rpchost <span class="keywordflow">is</span> <span class="keywordtype">None</span>:</div><div class="line"><a name="l00264"></a><span class="lineno"> 264</span>  <span class="keywordflow">return</span> []</div><div class="line"><a name="l00265"></a><span class="lineno"> 265</span> </div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span>  match = re.match(<span class="stringliteral">'(\[[0-9a-fA-f:]+\]|[^:]+)(?::([0-9]+))?$'</span>, rpchost)</div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span>  <span class="keywordflow">if</span> <span class="keywordflow">not</span> match:</div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span>  <span class="keywordflow">raise</span> ValueError(<span class="stringliteral">'Invalid RPC host spec '</span> + rpchost)</div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span> </div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span>  rpcconnect = match.group(1)</div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span>  rpcport = match.group(2)</div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span> </div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span>  <span class="keywordflow">if</span> rpcconnect.startswith(<span class="stringliteral">'['</span>): <span class="comment"># remove IPv6 [...] wrapping</span></div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span>  rpcconnect = rpcconnect[1:-1]</div><div class="line"><a name="l00275"></a><span class="lineno"> 275</span> </div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span>  rv = [<span class="stringliteral">'-rpcconnect='</span> + rpcconnect]</div><div class="line"><a name="l00277"></a><span class="lineno"> 277</span>  <span class="keywordflow">if</span> rpcport:</div><div class="line"><a name="l00278"></a><span class="lineno"> 278</span>  rv += [<span class="stringliteral">'-rpcport='</span> + rpcport]</div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span>  <span class="keywordflow">return</span> rv</div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span> </div><div class="line"><a name="l00281"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#aebc7ae4dc3512e677020141c7370b2e1"> 281</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#aebc7ae4dc3512e677020141c7370b2e1">start_node</a>(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None):</div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00283"></a><span class="lineno"> 283</span> <span class="stringliteral"> Start a dashd and return RPC connection to it</span></div><div class="line"><a name="l00284"></a><span class="lineno"> 284</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00285"></a><span class="lineno"> 285</span>  datadir = os.path.join(dirname, <span class="stringliteral">"node"</span>+str(i))</div><div class="line"><a name="l00286"></a><span class="lineno"> 286</span>  <span class="keywordflow">if</span> binary <span class="keywordflow">is</span> <span class="keywordtype">None</span>:</div><div class="line"><a name="l00287"></a><span class="lineno"> 287</span>  binary = os.getenv(<span class="stringliteral">"DASHD"</span>, <span class="stringliteral">"dashd"</span>)</div><div class="line"><a name="l00288"></a><span class="lineno"> 288</span>  <span class="comment"># RPC tests still depend on free transactions</span></div><div class="line"><a name="l00289"></a><span class="lineno"> 289</span>  args = [ binary, <span class="stringliteral">"-datadir="</span>+datadir, <span class="stringliteral">"-server"</span>, <span class="stringliteral">"-keypool=1"</span>, <span class="stringliteral">"-discover=0"</span>, <span class="stringliteral">"-rest"</span>, <span class="stringliteral">"-blockprioritysize=50000"</span>, <span class="stringliteral">"-mocktime="</span>+str(<a class="code" href="namespacetest__framework_1_1util.html#a4176bf733648642a46bbc3e14438f441">get_mocktime</a>()) ]</div><div class="line"><a name="l00290"></a><span class="lineno"> 290</span>  <span class="keywordflow">if</span> extra_args <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>: args.extend(extra_args)</div><div class="line"><a name="l00291"></a><span class="lineno"> 291</span>  bitcoind_processes[i] = subprocess.Popen(args)</div><div class="line"><a name="l00292"></a><span class="lineno"> 292</span>  <span class="keywordflow">if</span> os.getenv(<span class="stringliteral">"PYTHON_DEBUG"</span>, <span class="stringliteral">""</span>):</div><div class="line"><a name="l00293"></a><span class="lineno"> 293</span>  <span class="keywordflow">print</span> <span class="stringliteral">"start_node: dashd started, waiting for RPC to come up"</span></div><div class="line"><a name="l00294"></a><span class="lineno"> 294</span>  url = <a class="code" href="namespacetest__framework_1_1util.html#a016b1065dcfa9d79ebdb1b56d721c3ba">rpc_url</a>(i, rpchost)</div><div class="line"><a name="l00295"></a><span class="lineno"> 295</span>  <a class="code" href="namespacetest__framework_1_1util.html#a239cec5d2c7ebb76bac776573d2fe3ba">wait_for_bitcoind_start</a>(bitcoind_processes[i], url, i)</div><div class="line"><a name="l00296"></a><span class="lineno"> 296</span>  <span class="keywordflow">if</span> os.getenv(<span class="stringliteral">"PYTHON_DEBUG"</span>, <span class="stringliteral">""</span>):</div><div class="line"><a name="l00297"></a><span class="lineno"> 297</span>  <span class="keywordflow">print</span> <span class="stringliteral">"start_node: RPC succesfully started"</span></div><div class="line"><a name="l00298"></a><span class="lineno"> 298</span>  proxy = <a class="code" href="namespacetest__framework_1_1util.html#adf11fca732419a7289c9d119119b34f2">get_rpc_proxy</a>(url, i, timeout=timewait)</div><div class="line"><a name="l00299"></a><span class="lineno"> 299</span> </div><div class="line"><a name="l00300"></a><span class="lineno"> 300</span>  <span class="keywordflow">if</span> COVERAGE_DIR:</div><div class="line"><a name="l00301"></a><span class="lineno"> 301</span>  coverage.write_all_rpc_commands(COVERAGE_DIR, proxy)</div><div class="line"><a name="l00302"></a><span class="lineno"> 302</span> </div><div class="line"><a name="l00303"></a><span class="lineno"> 303</span>  <span class="keywordflow">return</span> proxy</div><div class="line"><a name="l00304"></a><span class="lineno"> 304</span> </div><div class="line"><a name="l00305"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#aa6b84bae918a356af030860efab10362"> 305</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#aa6b84bae918a356af030860efab10362">start_nodes</a>(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):</div><div class="line"><a name="l00306"></a><span class="lineno"> 306</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00307"></a><span class="lineno"> 307</span> <span class="stringliteral"> Start multiple dashds, return RPC connections to them</span></div><div class="line"><a name="l00308"></a><span class="lineno"> 308</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span>  <span class="keywordflow">if</span> extra_args <span class="keywordflow">is</span> <span class="keywordtype">None</span>: extra_args = [ <span class="keywordtype">None</span> <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(num_nodes) ]</div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span>  <span class="keywordflow">if</span> binary <span class="keywordflow">is</span> <span class="keywordtype">None</span>: binary = [ <span class="keywordtype">None</span> <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(num_nodes) ]</div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span>  rpcs = []</div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span>  <span class="keywordflow">try</span>:</div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(num_nodes):</div><div class="line"><a name="l00314"></a><span class="lineno"> 314</span>  rpcs.append(<a class="code" href="namespacetest__framework_1_1util.html#aebc7ae4dc3512e677020141c7370b2e1">start_node</a>(i, dirname, extra_args[i], rpchost, binary=binary[i]))</div><div class="line"><a name="l00315"></a><span class="lineno"> 315</span>  <span class="keywordflow">except</span>: <span class="comment"># If one node failed to start, stop the others</span></div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span>  <a class="code" href="namespacetest__framework_1_1util.html#ab86494439dc4a3b58f808c6b9897930c">stop_nodes</a>(rpcs)</div><div class="line"><a name="l00317"></a><span class="lineno"> 317</span>  <span class="keywordflow">raise</span></div><div class="line"><a name="l00318"></a><span class="lineno"> 318</span>  <span class="keywordflow">return</span> rpcs</div><div class="line"><a name="l00319"></a><span class="lineno"> 319</span> </div><div class="line"><a name="l00320"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d"> 320</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d">log_filename</a>(dirname, n_node, logname):</div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  <span class="keywordflow">return</span> os.path.join(dirname, <span class="stringliteral">"node"</span>+str(n_node), <span class="stringliteral">"regtest"</span>, logname)</div><div class="line"><a name="l00322"></a><span class="lineno"> 322</span> </div><div class="line"><a name="l00323"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#adedab36f7b224153aba7cefb50663d3c"> 323</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#adedab36f7b224153aba7cefb50663d3c">stop_node</a>(node, i):</div><div class="line"><a name="l00324"></a><span class="lineno"> 324</span>  node.stop()</div><div class="line"><a name="l00325"></a><span class="lineno"> 325</span>  bitcoind_processes[i].wait()</div><div class="line"><a name="l00326"></a><span class="lineno"> 326</span>  del bitcoind_processes[i]</div><div class="line"><a name="l00327"></a><span class="lineno"> 327</span> </div><div class="line"><a name="l00328"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ab86494439dc4a3b58f808c6b9897930c"> 328</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ab86494439dc4a3b58f808c6b9897930c">stop_nodes</a>(nodes):</div><div class="line"><a name="l00329"></a><span class="lineno"> 329</span>  <span class="keywordflow">for</span> node <span class="keywordflow">in</span> nodes:</div><div class="line"><a name="l00330"></a><span class="lineno"> 330</span>  node.stop()</div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span>  del nodes[:] <span class="comment"># Emptying array closes connections as a side effect</span></div><div class="line"><a name="l00332"></a><span class="lineno"> 332</span> </div><div class="line"><a name="l00333"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a6750da97ae214f27a180d67ed8c7fb37"> 333</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a6750da97ae214f27a180d67ed8c7fb37">set_node_times</a>(nodes, t):</div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span>  <span class="keywordflow">for</span> node <span class="keywordflow">in</span> nodes:</div><div class="line"><a name="l00335"></a><span class="lineno"> 335</span>  node.setmocktime(t)</div><div class="line"><a name="l00336"></a><span class="lineno"> 336</span> </div><div class="line"><a name="l00337"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a9e0ced9f6fa4bdbcfcd6e52363cfba74"> 337</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a9e0ced9f6fa4bdbcfcd6e52363cfba74">wait_bitcoinds</a>():</div><div class="line"><a name="l00338"></a><span class="lineno"> 338</span>  <span class="comment"># Wait for all bitcoinds to cleanly exit</span></div><div class="line"><a name="l00339"></a><span class="lineno"> 339</span>  <span class="keywordflow">for</span> bitcoind <span class="keywordflow">in</span> bitcoind_processes.values():</div><div class="line"><a name="l00340"></a><span class="lineno"> 340</span>  bitcoind.wait()</div><div class="line"><a name="l00341"></a><span class="lineno"> 341</span>  bitcoind_processes.clear()</div><div class="line"><a name="l00342"></a><span class="lineno"> 342</span> </div><div class="line"><a name="l00343"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#aa1eacfbd44ba6019d659733acf4b1a71"> 343</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#aa1eacfbd44ba6019d659733acf4b1a71">connect_nodes</a>(from_connection, node_num):</div><div class="line"><a name="l00344"></a><span class="lineno"> 344</span>  ip_port = <span class="stringliteral">"127.0.0.1:"</span>+str(<a class="code" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">p2p_port</a>(node_num))</div><div class="line"><a name="l00345"></a><span class="lineno"> 345</span>  from_connection.addnode(ip_port, <span class="stringliteral">"onetry"</span>)</div><div class="line"><a name="l00346"></a><span class="lineno"> 346</span>  <span class="comment"># poll until version handshake complete to avoid race conditions</span></div><div class="line"><a name="l00347"></a><span class="lineno"> 347</span>  <span class="comment"># with transaction relaying</span></div><div class="line"><a name="l00348"></a><span class="lineno"> 348</span>  <span class="keywordflow">while</span> any(peer[<span class="stringliteral">'version'</span>] == 0 <span class="keywordflow">for</span> peer <span class="keywordflow">in</span> from_connection.getpeerinfo()):</div><div class="line"><a name="l00349"></a><span class="lineno"> 349</span>  time.sleep(0.1)</div><div class="line"><a name="l00350"></a><span class="lineno"> 350</span> </div><div class="line"><a name="l00351"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a8284a471708986c9fb9d9b3fc13141ae"> 351</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a8284a471708986c9fb9d9b3fc13141ae">connect_nodes_bi</a>(nodes, a, b):</div><div class="line"><a name="l00352"></a><span class="lineno"> 352</span>  <a class="code" href="namespacetest__framework_1_1util.html#aa1eacfbd44ba6019d659733acf4b1a71">connect_nodes</a>(nodes[a], b)</div><div class="line"><a name="l00353"></a><span class="lineno"> 353</span>  <a class="code" href="namespacetest__framework_1_1util.html#aa1eacfbd44ba6019d659733acf4b1a71">connect_nodes</a>(nodes[b], a)</div><div class="line"><a name="l00354"></a><span class="lineno"> 354</span> </div><div class="line"><a name="l00355"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a48dd2950941d1a9c5651343b7e894e49"> 355</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a48dd2950941d1a9c5651343b7e894e49">find_output</a>(node, txid, amount):</div><div class="line"><a name="l00356"></a><span class="lineno"> 356</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00357"></a><span class="lineno"> 357</span> <span class="stringliteral"> Return index to output of txid with value amount</span></div><div class="line"><a name="l00358"></a><span class="lineno"> 358</span> <span class="stringliteral"> Raises exception if there is none.</span></div><div class="line"><a name="l00359"></a><span class="lineno"> 359</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00360"></a><span class="lineno"> 360</span>  txdata = node.getrawtransaction(txid, 1)</div><div class="line"><a name="l00361"></a><span class="lineno"> 361</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> range(len(txdata[<span class="stringliteral">"vout"</span>])):</div><div class="line"><a name="l00362"></a><span class="lineno"> 362</span>  <span class="keywordflow">if</span> txdata[<span class="stringliteral">"vout"</span>][i][<span class="stringliteral">"value"</span>] == amount:</div><div class="line"><a name="l00363"></a><span class="lineno"> 363</span>  <span class="keywordflow">return</span> i</div><div class="line"><a name="l00364"></a><span class="lineno"> 364</span>  <span class="keywordflow">raise</span> RuntimeError(<span class="stringliteral">"find_output txid %s : %s not found"</span>%(txid,str(amount)))</div><div class="line"><a name="l00365"></a><span class="lineno"> 365</span> </div><div class="line"><a name="l00366"></a><span class="lineno"> 366</span> </div><div class="line"><a name="l00367"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#add8e7b0a77dddd68bdb4bd3514f58da6"> 367</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#add8e7b0a77dddd68bdb4bd3514f58da6">gather_inputs</a>(from_node, amount_needed, confirmations_required=1):</div><div class="line"><a name="l00368"></a><span class="lineno"> 368</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00369"></a><span class="lineno"> 369</span> <span class="stringliteral"> Return a random set of unspent txouts that are enough to pay amount_needed</span></div><div class="line"><a name="l00370"></a><span class="lineno"> 370</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00371"></a><span class="lineno"> 371</span>  assert(confirmations_required >=0)</div><div class="line"><a name="l00372"></a><span class="lineno"> 372</span>  utxo = from_node.listunspent(confirmations_required)</div><div class="line"><a name="l00373"></a><span class="lineno"> 373</span>  random.shuffle(utxo)</div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span>  inputs = []</div><div class="line"><a name="l00375"></a><span class="lineno"> 375</span>  total_in = Decimal(<span class="stringliteral">"0.00000000"</span>)</div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span>  <span class="keywordflow">while</span> total_in < amount_needed <span class="keywordflow">and</span> len(utxo) > 0:</div><div class="line"><a name="l00377"></a><span class="lineno"> 377</span>  t = utxo.pop()</div><div class="line"><a name="l00378"></a><span class="lineno"> 378</span>  total_in += t[<span class="stringliteral">"amount"</span>]</div><div class="line"><a name="l00379"></a><span class="lineno"> 379</span>  inputs.append({ <span class="stringliteral">"txid"</span> : t[<span class="stringliteral">"txid"</span>], <span class="stringliteral">"vout"</span> : t[<span class="stringliteral">"vout"</span>], <span class="stringliteral">"address"</span> : t[<span class="stringliteral">"address"</span>] } )</div><div class="line"><a name="l00380"></a><span class="lineno"> 380</span>  <span class="keywordflow">if</span> total_in < amount_needed:</div><div class="line"><a name="l00381"></a><span class="lineno"> 381</span>  <span class="keywordflow">raise</span> RuntimeError(<span class="stringliteral">"Insufficient funds: need %d, have %d"</span>%(amount_needed, total_in))</div><div class="line"><a name="l00382"></a><span class="lineno"> 382</span>  <span class="keywordflow">return</span> (total_in, inputs)</div><div class="line"><a name="l00383"></a><span class="lineno"> 383</span> </div><div class="line"><a name="l00384"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a1b05b9466611848d89d6abac1826fe66"> 384</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a1b05b9466611848d89d6abac1826fe66">make_change</a>(from_node, amount_in, amount_out, fee):</div><div class="line"><a name="l00385"></a><span class="lineno"> 385</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00386"></a><span class="lineno"> 386</span> <span class="stringliteral"> Create change output(s), return them</span></div><div class="line"><a name="l00387"></a><span class="lineno"> 387</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00388"></a><span class="lineno"> 388</span>  outputs = {}</div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span>  amount = amount_out+fee</div><div class="line"><a name="l00390"></a><span class="lineno"> 390</span>  change = amount_in - amount</div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span>  <span class="keywordflow">if</span> change > amount*2:</div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span>  <span class="comment"># Create an extra change output to break up big inputs</span></div><div class="line"><a name="l00393"></a><span class="lineno"> 393</span>  change_address = from_node.getnewaddress()</div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span>  <span class="comment"># Split change in two, being careful of rounding:</span></div><div class="line"><a name="l00395"></a><span class="lineno"> 395</span>  outputs[change_address] = Decimal(change/2).quantize(Decimal(<span class="stringliteral">'0.00000001'</span>), rounding=ROUND_DOWN)</div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span>  change = amount_in - amount - outputs[change_address]</div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span>  <span class="keywordflow">if</span> change > 0:</div><div class="line"><a name="l00398"></a><span class="lineno"> 398</span>  outputs[from_node.getnewaddress()] = change</div><div class="line"><a name="l00399"></a><span class="lineno"> 399</span>  <span class="keywordflow">return</span> outputs</div><div class="line"><a name="l00400"></a><span class="lineno"> 400</span> </div><div class="line"><a name="l00401"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ae3437fca5527c14df602a532e66e0076"> 401</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ae3437fca5527c14df602a532e66e0076">send_zeropri_transaction</a>(from_node, to_node, amount, fee):</div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00403"></a><span class="lineno"> 403</span> <span class="stringliteral"> Create&broadcast a zero-priority transaction.</span></div><div class="line"><a name="l00404"></a><span class="lineno"> 404</span> <span class="stringliteral"> Returns (txid, hex-encoded-txdata)</span></div><div class="line"><a name="l00405"></a><span class="lineno"> 405</span> <span class="stringliteral"> Ensures transaction is zero-priority by first creating a send-to-self,</span></div><div class="line"><a name="l00406"></a><span class="lineno"> 406</span> <span class="stringliteral"> then using its output</span></div><div class="line"><a name="l00407"></a><span class="lineno"> 407</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00408"></a><span class="lineno"> 408</span> </div><div class="line"><a name="l00409"></a><span class="lineno"> 409</span>  <span class="comment"># Create a send-to-self with confirmed inputs:</span></div><div class="line"><a name="l00410"></a><span class="lineno"> 410</span>  self_address = from_node.getnewaddress()</div><div class="line"><a name="l00411"></a><span class="lineno"> 411</span>  (total_in, inputs) = <a class="code" href="namespacetest__framework_1_1util.html#add8e7b0a77dddd68bdb4bd3514f58da6">gather_inputs</a>(from_node, amount+fee*2)</div><div class="line"><a name="l00412"></a><span class="lineno"> 412</span>  outputs = <a class="code" href="namespacetest__framework_1_1util.html#a1b05b9466611848d89d6abac1826fe66">make_change</a>(from_node, total_in, amount+fee, fee)</div><div class="line"><a name="l00413"></a><span class="lineno"> 413</span>  outputs[self_address] = float(amount+fee)</div><div class="line"><a name="l00414"></a><span class="lineno"> 414</span> </div><div class="line"><a name="l00415"></a><span class="lineno"> 415</span>  self_rawtx = from_node.createrawtransaction(inputs, outputs)</div><div class="line"><a name="l00416"></a><span class="lineno"> 416</span>  self_signresult = from_node.signrawtransaction(self_rawtx)</div><div class="line"><a name="l00417"></a><span class="lineno"> 417</span>  self_txid = from_node.sendrawtransaction(self_signresult[<span class="stringliteral">"hex"</span>], <span class="keyword">True</span>)</div><div class="line"><a name="l00418"></a><span class="lineno"> 418</span> </div><div class="line"><a name="l00419"></a><span class="lineno"> 419</span>  vout = <a class="code" href="namespacetest__framework_1_1util.html#a48dd2950941d1a9c5651343b7e894e49">find_output</a>(from_node, self_txid, amount+fee)</div><div class="line"><a name="l00420"></a><span class="lineno"> 420</span>  <span class="comment"># Now immediately spend the output to create a 1-input, 1-output</span></div><div class="line"><a name="l00421"></a><span class="lineno"> 421</span>  <span class="comment"># zero-priority transaction:</span></div><div class="line"><a name="l00422"></a><span class="lineno"> 422</span>  inputs = [ { <span class="stringliteral">"txid"</span> : self_txid, <span class="stringliteral">"vout"</span> : vout } ]</div><div class="line"><a name="l00423"></a><span class="lineno"> 423</span>  outputs = { to_node.getnewaddress() : float(amount) }</div><div class="line"><a name="l00424"></a><span class="lineno"> 424</span> </div><div class="line"><a name="l00425"></a><span class="lineno"> 425</span>  rawtx = from_node.createrawtransaction(inputs, outputs)</div><div class="line"><a name="l00426"></a><span class="lineno"> 426</span>  signresult = from_node.signrawtransaction(rawtx)</div><div class="line"><a name="l00427"></a><span class="lineno"> 427</span>  txid = from_node.sendrawtransaction(signresult[<span class="stringliteral">"hex"</span>], <span class="keyword">True</span>)</div><div class="line"><a name="l00428"></a><span class="lineno"> 428</span> </div><div class="line"><a name="l00429"></a><span class="lineno"> 429</span>  <span class="keywordflow">return</span> (txid, signresult[<span class="stringliteral">"hex"</span>])</div><div class="line"><a name="l00430"></a><span class="lineno"> 430</span> </div><div class="line"><a name="l00431"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a5a904f1d65ae6c90ce714e2667565785"> 431</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a5a904f1d65ae6c90ce714e2667565785">random_zeropri_transaction</a>(nodes, amount, min_fee, fee_increment, fee_variants):</div><div class="line"><a name="l00432"></a><span class="lineno"> 432</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00433"></a><span class="lineno"> 433</span> <span class="stringliteral"> Create a random zero-priority transaction.</span></div><div class="line"><a name="l00434"></a><span class="lineno"> 434</span> <span class="stringliteral"> Returns (txid, hex-encoded-transaction-data, fee)</span></div><div class="line"><a name="l00435"></a><span class="lineno"> 435</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00436"></a><span class="lineno"> 436</span>  from_node = random.choice(nodes)</div><div class="line"><a name="l00437"></a><span class="lineno"> 437</span>  to_node = random.choice(nodes)</div><div class="line"><a name="l00438"></a><span class="lineno"> 438</span>  fee = min_fee + fee_increment*random.randint(0,fee_variants)</div><div class="line"><a name="l00439"></a><span class="lineno"> 439</span>  (txid, txhex) = <a class="code" href="namespacetest__framework_1_1util.html#ae3437fca5527c14df602a532e66e0076">send_zeropri_transaction</a>(from_node, to_node, amount, fee)</div><div class="line"><a name="l00440"></a><span class="lineno"> 440</span>  <span class="keywordflow">return</span> (txid, txhex, fee)</div><div class="line"><a name="l00441"></a><span class="lineno"> 441</span> </div><div class="line"><a name="l00442"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a2060906ea1bd7e3032ad3718160f28fd"> 442</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a2060906ea1bd7e3032ad3718160f28fd">random_transaction</a>(nodes, amount, min_fee, fee_increment, fee_variants):</div><div class="line"><a name="l00443"></a><span class="lineno"> 443</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00444"></a><span class="lineno"> 444</span> <span class="stringliteral"> Create a random transaction.</span></div><div class="line"><a name="l00445"></a><span class="lineno"> 445</span> <span class="stringliteral"> Returns (txid, hex-encoded-transaction-data, fee)</span></div><div class="line"><a name="l00446"></a><span class="lineno"> 446</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00447"></a><span class="lineno"> 447</span>  from_node = random.choice(nodes)</div><div class="line"><a name="l00448"></a><span class="lineno"> 448</span>  to_node = random.choice(nodes)</div><div class="line"><a name="l00449"></a><span class="lineno"> 449</span>  fee = min_fee + fee_increment*random.randint(0,fee_variants)</div><div class="line"><a name="l00450"></a><span class="lineno"> 450</span> </div><div class="line"><a name="l00451"></a><span class="lineno"> 451</span>  (total_in, inputs) = <a class="code" href="namespacetest__framework_1_1util.html#add8e7b0a77dddd68bdb4bd3514f58da6">gather_inputs</a>(from_node, amount+fee)</div><div class="line"><a name="l00452"></a><span class="lineno"> 452</span>  outputs = <a class="code" href="namespacetest__framework_1_1util.html#a1b05b9466611848d89d6abac1826fe66">make_change</a>(from_node, total_in, amount, fee)</div><div class="line"><a name="l00453"></a><span class="lineno"> 453</span>  outputs[to_node.getnewaddress()] = float(amount)</div><div class="line"><a name="l00454"></a><span class="lineno"> 454</span> </div><div class="line"><a name="l00455"></a><span class="lineno"> 455</span>  rawtx = from_node.createrawtransaction(inputs, outputs)</div><div class="line"><a name="l00456"></a><span class="lineno"> 456</span>  signresult = from_node.signrawtransaction(rawtx)</div><div class="line"><a name="l00457"></a><span class="lineno"> 457</span>  txid = from_node.sendrawtransaction(signresult[<span class="stringliteral">"hex"</span>], <span class="keyword">True</span>)</div><div class="line"><a name="l00458"></a><span class="lineno"> 458</span> </div><div class="line"><a name="l00459"></a><span class="lineno"> 459</span>  <span class="keywordflow">return</span> (txid, signresult[<span class="stringliteral">"hex"</span>], fee)</div><div class="line"><a name="l00460"></a><span class="lineno"> 460</span> </div><div class="line"><a name="l00461"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b"> 461</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(thing1, thing2):</div><div class="line"><a name="l00462"></a><span class="lineno"> 462</span>  <span class="keywordflow">if</span> thing1 != thing2:</div><div class="line"><a name="l00463"></a><span class="lineno"> 463</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"%s != %s"</span>%(str(thing1),str(thing2)))</div><div class="line"><a name="l00464"></a><span class="lineno"> 464</span> </div><div class="line"><a name="l00465"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a38c565d0ecd75410e6fb90126c743482"> 465</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a38c565d0ecd75410e6fb90126c743482">assert_greater_than</a>(thing1, thing2):</div><div class="line"><a name="l00466"></a><span class="lineno"> 466</span>  <span class="keywordflow">if</span> thing1 <= thing2:</div><div class="line"><a name="l00467"></a><span class="lineno"> 467</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"%s <= %s"</span>%(str(thing1),str(thing2)))</div><div class="line"><a name="l00468"></a><span class="lineno"> 468</span> </div><div class="line"><a name="l00469"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a0c2ac88b78189fa2112558f2b3281b98"> 469</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a0c2ac88b78189fa2112558f2b3281b98">assert_raises</a>(exc, fun, *args, **kwds):</div><div class="line"><a name="l00470"></a><span class="lineno"> 470</span>  <span class="keywordflow">try</span>:</div><div class="line"><a name="l00471"></a><span class="lineno"> 471</span>  fun(*args, **kwds)</div><div class="line"><a name="l00472"></a><span class="lineno"> 472</span>  <span class="keywordflow">except</span> exc:</div><div class="line"><a name="l00473"></a><span class="lineno"> 473</span>  <span class="keywordflow">pass</span></div><div class="line"><a name="l00474"></a><span class="lineno"> 474</span>  <span class="keywordflow">except</span> Exception <span class="keyword">as</span> e:</div><div class="line"><a name="l00475"></a><span class="lineno"> 475</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"Unexpected exception raised: "</span>+type(e).__name__)</div><div class="line"><a name="l00476"></a><span class="lineno"> 476</span>  <span class="keywordflow">else</span>:</div><div class="line"><a name="l00477"></a><span class="lineno"> 477</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"No exception raised"</span>)</div><div class="line"><a name="l00478"></a><span class="lineno"> 478</span> </div><div class="line"><a name="l00479"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ab9abe249755797f0498d9f5509aa25b4"> 479</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ab9abe249755797f0498d9f5509aa25b4">assert_is_hex_string</a>(string):</div><div class="line"><a name="l00480"></a><span class="lineno"> 480</span>  <span class="keywordflow">try</span>:</div><div class="line"><a name="l00481"></a><span class="lineno"> 481</span>  int(string, 16)</div><div class="line"><a name="l00482"></a><span class="lineno"> 482</span>  <span class="keywordflow">except</span> Exception <span class="keyword">as</span> e:</div><div class="line"><a name="l00483"></a><span class="lineno"> 483</span>  <span class="keywordflow">raise</span> AssertionError(</div><div class="line"><a name="l00484"></a><span class="lineno"> 484</span>  <span class="stringliteral">"Couldn't interpret %r as hexadecimal; raised: %s"</span> % (string, e))</div><div class="line"><a name="l00485"></a><span class="lineno"> 485</span> </div><div class="line"><a name="l00486"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#abb8795de00113ae4bb365c0590fa1aa7"> 486</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#abb8795de00113ae4bb365c0590fa1aa7">assert_is_hash_string</a>(string, length=64):</div><div class="line"><a name="l00487"></a><span class="lineno"> 487</span>  <span class="keywordflow">if</span> <span class="keywordflow">not</span> isinstance(string, basestring):</div><div class="line"><a name="l00488"></a><span class="lineno"> 488</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"Expected a string, got type %r"</span> % type(string))</div><div class="line"><a name="l00489"></a><span class="lineno"> 489</span>  <span class="keywordflow">elif</span> length <span class="keywordflow">and</span> len(string) != length:</div><div class="line"><a name="l00490"></a><span class="lineno"> 490</span>  <span class="keywordflow">raise</span> AssertionError(</div><div class="line"><a name="l00491"></a><span class="lineno"> 491</span>  <span class="stringliteral">"String of length %d expected; got %d"</span> % (length, len(string)))</div><div class="line"><a name="l00492"></a><span class="lineno"> 492</span>  <span class="keywordflow">elif</span> <span class="keywordflow">not</span> re.match(<span class="stringliteral">'[abcdef0-9]+$'</span>, string):</div><div class="line"><a name="l00493"></a><span class="lineno"> 493</span>  <span class="keywordflow">raise</span> AssertionError(</div><div class="line"><a name="l00494"></a><span class="lineno"> 494</span>  <span class="stringliteral">"String %r contains invalid characters for a hash."</span> % string)</div><div class="line"><a name="l00495"></a><span class="lineno"> 495</span> </div><div class="line"><a name="l00496"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a2ffb3a7be720230b0e302867296bd893"> 496</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a2ffb3a7be720230b0e302867296bd893">assert_array_result</a>(object_array, to_match, expected, should_not_find = False):</div><div class="line"><a name="l00497"></a><span class="lineno"> 497</span>  <span class="stringliteral">"""</span></div><div class="line"><a name="l00498"></a><span class="lineno"> 498</span> <span class="stringliteral"> Pass in array of JSON objects, a dictionary with key/value pairs</span></div><div class="line"><a name="l00499"></a><span class="lineno"> 499</span> <span class="stringliteral"> to match against, and another dictionary with expected key/value</span></div><div class="line"><a name="l00500"></a><span class="lineno"> 500</span> <span class="stringliteral"> pairs.</span></div><div class="line"><a name="l00501"></a><span class="lineno"> 501</span> <span class="stringliteral"> If the should_not_find flag is true, to_match should not be found</span></div><div class="line"><a name="l00502"></a><span class="lineno"> 502</span> <span class="stringliteral"> in object_array</span></div><div class="line"><a name="l00503"></a><span class="lineno"> 503</span> <span class="stringliteral"> """</span></div><div class="line"><a name="l00504"></a><span class="lineno"> 504</span>  <span class="keywordflow">if</span> should_not_find == <span class="keyword">True</span>:</div><div class="line"><a name="l00505"></a><span class="lineno"> 505</span>  <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(expected, { })</div><div class="line"><a name="l00506"></a><span class="lineno"> 506</span>  num_matched = 0</div><div class="line"><a name="l00507"></a><span class="lineno"> 507</span>  <span class="keywordflow">for</span> item <span class="keywordflow">in</span> object_array:</div><div class="line"><a name="l00508"></a><span class="lineno"> 508</span>  all_match = <span class="keyword">True</span></div><div class="line"><a name="l00509"></a><span class="lineno"> 509</span>  <span class="keywordflow">for</span> key,value <span class="keywordflow">in</span> to_match.items():</div><div class="line"><a name="l00510"></a><span class="lineno"> 510</span>  <span class="keywordflow">if</span> item[key] != value:</div><div class="line"><a name="l00511"></a><span class="lineno"> 511</span>  all_match = <span class="keyword">False</span></div><div class="line"><a name="l00512"></a><span class="lineno"> 512</span>  <span class="keywordflow">if</span> <span class="keywordflow">not</span> all_match:</div><div class="line"><a name="l00513"></a><span class="lineno"> 513</span>  <span class="keywordflow">continue</span></div><div class="line"><a name="l00514"></a><span class="lineno"> 514</span>  <span class="keywordflow">elif</span> should_not_find == <span class="keyword">True</span>:</div><div class="line"><a name="l00515"></a><span class="lineno"> 515</span>  num_matched = num_matched+1</div><div class="line"><a name="l00516"></a><span class="lineno"> 516</span>  <span class="keywordflow">for</span> key,value <span class="keywordflow">in</span> expected.items():</div><div class="line"><a name="l00517"></a><span class="lineno"> 517</span>  <span class="keywordflow">if</span> item[key] != value:</div><div class="line"><a name="l00518"></a><span class="lineno"> 518</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"%s : expected %s=%s"</span>%(str(item), str(key), str(value)))</div><div class="line"><a name="l00519"></a><span class="lineno"> 519</span>  num_matched = num_matched+1</div><div class="line"><a name="l00520"></a><span class="lineno"> 520</span>  <span class="keywordflow">if</span> num_matched == 0 <span class="keywordflow">and</span> should_not_find != <span class="keyword">True</span>:</div><div class="line"><a name="l00521"></a><span class="lineno"> 521</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"No objects matched %s"</span>%(str(to_match)))</div><div class="line"><a name="l00522"></a><span class="lineno"> 522</span>  <span class="keywordflow">if</span> num_matched > 0 <span class="keywordflow">and</span> should_not_find == <span class="keyword">True</span>:</div><div class="line"><a name="l00523"></a><span class="lineno"> 523</span>  <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">"Objects were found %s"</span>%(str(to_match)))</div><div class="line"><a name="l00524"></a><span class="lineno"> 524</span> </div><div class="line"><a name="l00525"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a2d6cbb1015ca6a97273de4dcf5be900c"> 525</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a2d6cbb1015ca6a97273de4dcf5be900c">satoshi_round</a>(amount):</div><div class="line"><a name="l00526"></a><span class="lineno"> 526</span>  <span class="keywordflow">return</span> Decimal(amount).quantize(Decimal(<span class="stringliteral">'0.00000001'</span>), rounding=ROUND_DOWN)</div><div class="line"><a name="l00527"></a><span class="lineno"> 527</span> </div><div class="line"><a name="l00528"></a><span class="lineno"> 528</span> <span class="comment"># Helper to create at least "count" utxos</span></div><div class="line"><a name="l00529"></a><span class="lineno"> 529</span> <span class="comment"># Pass in a fee that is sufficient for relay and mining new transactions.</span></div><div class="line"><a name="l00530"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#ad2a1eac247f3595c8d70f05c97edc542"> 530</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#ad2a1eac247f3595c8d70f05c97edc542">create_confirmed_utxos</a>(fee, node, count):</div><div class="line"><a name="l00531"></a><span class="lineno"> 531</span>  node.generate(int(0.5*count)+101)</div><div class="line"><a name="l00532"></a><span class="lineno"> 532</span>  utxos = node.listunspent()</div><div class="line"><a name="l00533"></a><span class="lineno"> 533</span>  iterations = count - len(utxos)</div><div class="line"><a name="l00534"></a><span class="lineno"> 534</span>  addr1 = node.getnewaddress()</div><div class="line"><a name="l00535"></a><span class="lineno"> 535</span>  addr2 = node.getnewaddress()</div><div class="line"><a name="l00536"></a><span class="lineno"> 536</span>  <span class="keywordflow">if</span> iterations <= 0:</div><div class="line"><a name="l00537"></a><span class="lineno"> 537</span>  <span class="keywordflow">return</span> utxos</div><div class="line"><a name="l00538"></a><span class="lineno"> 538</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange(iterations):</div><div class="line"><a name="l00539"></a><span class="lineno"> 539</span>  t = utxos.pop()</div><div class="line"><a name="l00540"></a><span class="lineno"> 540</span>  inputs = []</div><div class="line"><a name="l00541"></a><span class="lineno"> 541</span>  inputs.append({ <span class="stringliteral">"txid"</span> : t[<span class="stringliteral">"txid"</span>], <span class="stringliteral">"vout"</span> : t[<span class="stringliteral">"vout"</span>]})</div><div class="line"><a name="l00542"></a><span class="lineno"> 542</span>  outputs = {}</div><div class="line"><a name="l00543"></a><span class="lineno"> 543</span>  send_value = t[<span class="stringliteral">'amount'</span>] - fee</div><div class="line"><a name="l00544"></a><span class="lineno"> 544</span>  outputs[addr1] = <a class="code" href="namespacetest__framework_1_1util.html#a2d6cbb1015ca6a97273de4dcf5be900c">satoshi_round</a>(send_value/2)</div><div class="line"><a name="l00545"></a><span class="lineno"> 545</span>  outputs[addr2] = <a class="code" href="namespacetest__framework_1_1util.html#a2d6cbb1015ca6a97273de4dcf5be900c">satoshi_round</a>(send_value/2)</div><div class="line"><a name="l00546"></a><span class="lineno"> 546</span>  raw_tx = node.createrawtransaction(inputs, outputs)</div><div class="line"><a name="l00547"></a><span class="lineno"> 547</span>  signed_tx = node.signrawtransaction(raw_tx)[<span class="stringliteral">"hex"</span>]</div><div class="line"><a name="l00548"></a><span class="lineno"> 548</span>  txid = node.sendrawtransaction(signed_tx)</div><div class="line"><a name="l00549"></a><span class="lineno"> 549</span> </div><div class="line"><a name="l00550"></a><span class="lineno"> 550</span>  <span class="keywordflow">while</span> (node.getmempoolinfo()[<span class="stringliteral">'size'</span>] > 0):</div><div class="line"><a name="l00551"></a><span class="lineno"> 551</span>  node.generate(1)</div><div class="line"><a name="l00552"></a><span class="lineno"> 552</span> </div><div class="line"><a name="l00553"></a><span class="lineno"> 553</span>  utxos = node.listunspent()</div><div class="line"><a name="l00554"></a><span class="lineno"> 554</span>  assert(len(utxos) >= count)</div><div class="line"><a name="l00555"></a><span class="lineno"> 555</span>  <span class="keywordflow">return</span> utxos</div><div class="line"><a name="l00556"></a><span class="lineno"> 556</span> </div><div class="line"><a name="l00557"></a><span class="lineno"> 557</span> <span class="comment"># Create large OP_RETURN txouts that can be appended to a transaction</span></div><div class="line"><a name="l00558"></a><span class="lineno"> 558</span> <span class="comment"># to make it large (helper for constructing large transactions).</span></div><div class="line"><a name="l00559"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a8fc6d48b2e47cf4a444310feff09ca5a"> 559</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a8fc6d48b2e47cf4a444310feff09ca5a">gen_return_txouts</a>():</div><div class="line"><a name="l00560"></a><span class="lineno"> 560</span>  <span class="comment"># Some pre-processing to create a bunch of OP_RETURN txouts to insert into transactions we create</span></div><div class="line"><a name="l00561"></a><span class="lineno"> 561</span>  <span class="comment"># So we have big transactions (and therefore can't fit very many into each block)</span></div><div class="line"><a name="l00562"></a><span class="lineno"> 562</span>  <span class="comment"># create one script_pubkey</span></div><div class="line"><a name="l00563"></a><span class="lineno"> 563</span>  script_pubkey = <span class="stringliteral">"6a4d0200"</span> <span class="comment">#OP_RETURN OP_PUSH2 512 bytes</span></div><div class="line"><a name="l00564"></a><span class="lineno"> 564</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange (512):</div><div class="line"><a name="l00565"></a><span class="lineno"> 565</span>  script_pubkey = script_pubkey + <span class="stringliteral">"01"</span></div><div class="line"><a name="l00566"></a><span class="lineno"> 566</span>  <span class="comment"># concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change</span></div><div class="line"><a name="l00567"></a><span class="lineno"> 567</span>  txouts = <span class="stringliteral">"81"</span></div><div class="line"><a name="l00568"></a><span class="lineno"> 568</span>  <span class="keywordflow">for</span> k <span class="keywordflow">in</span> xrange(128):</div><div class="line"><a name="l00569"></a><span class="lineno"> 569</span>  <span class="comment"># add txout value</span></div><div class="line"><a name="l00570"></a><span class="lineno"> 570</span>  txouts = txouts + <span class="stringliteral">"0000000000000000"</span></div><div class="line"><a name="l00571"></a><span class="lineno"> 571</span>  <span class="comment"># add length of script_pubkey</span></div><div class="line"><a name="l00572"></a><span class="lineno"> 572</span>  txouts = txouts + <span class="stringliteral">"fd0402"</span></div><div class="line"><a name="l00573"></a><span class="lineno"> 573</span>  <span class="comment"># add script_pubkey</span></div><div class="line"><a name="l00574"></a><span class="lineno"> 574</span>  txouts = txouts + script_pubkey</div><div class="line"><a name="l00575"></a><span class="lineno"> 575</span>  <span class="keywordflow">return</span> txouts</div><div class="line"><a name="l00576"></a><span class="lineno"> 576</span> </div><div class="line"><a name="l00577"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a9666cce08677f16638efd2207c3855e2"> 577</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a9666cce08677f16638efd2207c3855e2">create_tx</a>(node, coinbase, to_address, amount):</div><div class="line"><a name="l00578"></a><span class="lineno"> 578</span>  inputs = [{ <span class="stringliteral">"txid"</span> : coinbase, <span class="stringliteral">"vout"</span> : 0}]</div><div class="line"><a name="l00579"></a><span class="lineno"> 579</span>  outputs = { to_address : amount }</div><div class="line"><a name="l00580"></a><span class="lineno"> 580</span>  rawtx = node.createrawtransaction(inputs, outputs)</div><div class="line"><a name="l00581"></a><span class="lineno"> 581</span>  signresult = node.signrawtransaction(rawtx)</div><div class="line"><a name="l00582"></a><span class="lineno"> 582</span>  <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(signresult[<span class="stringliteral">"complete"</span>], <span class="keyword">True</span>)</div><div class="line"><a name="l00583"></a><span class="lineno"> 583</span>  <span class="keywordflow">return</span> signresult[<span class="stringliteral">"hex"</span>]</div><div class="line"><a name="l00584"></a><span class="lineno"> 584</span> </div><div class="line"><a name="l00585"></a><span class="lineno"> 585</span> <span class="comment"># Create a spend of each passed-in utxo, splicing in "txouts" to each raw</span></div><div class="line"><a name="l00586"></a><span class="lineno"> 586</span> <span class="comment"># transaction to make it large. See gen_return_txouts() above.</span></div><div class="line"><a name="l00587"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#aa4d1ef0eb05b1ea365f163a9c0112e5c"> 587</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#aa4d1ef0eb05b1ea365f163a9c0112e5c">create_lots_of_big_transactions</a>(node, txouts, utxos, fee):</div><div class="line"><a name="l00588"></a><span class="lineno"> 588</span>  addr = node.getnewaddress()</div><div class="line"><a name="l00589"></a><span class="lineno"> 589</span>  txids = []</div><div class="line"><a name="l00590"></a><span class="lineno"> 590</span>  <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange(len(utxos)):</div><div class="line"><a name="l00591"></a><span class="lineno"> 591</span>  t = utxos.pop()</div><div class="line"><a name="l00592"></a><span class="lineno"> 592</span>  inputs = []</div><div class="line"><a name="l00593"></a><span class="lineno"> 593</span>  inputs.append({ <span class="stringliteral">"txid"</span> : t[<span class="stringliteral">"txid"</span>], <span class="stringliteral">"vout"</span> : t[<span class="stringliteral">"vout"</span>]})</div><div class="line"><a name="l00594"></a><span class="lineno"> 594</span>  outputs = {}</div><div class="line"><a name="l00595"></a><span class="lineno"> 595</span>  send_value = t[<span class="stringliteral">'amount'</span>] - fee</div><div class="line"><a name="l00596"></a><span class="lineno"> 596</span>  outputs[addr] = <a class="code" href="namespacetest__framework_1_1util.html#a2d6cbb1015ca6a97273de4dcf5be900c">satoshi_round</a>(send_value)</div><div class="line"><a name="l00597"></a><span class="lineno"> 597</span>  rawtx = node.createrawtransaction(inputs, outputs)</div><div class="line"><a name="l00598"></a><span class="lineno"> 598</span>  newtx = rawtx[0:92]</div><div class="line"><a name="l00599"></a><span class="lineno"> 599</span>  newtx = newtx + txouts</div><div class="line"><a name="l00600"></a><span class="lineno"> 600</span>  newtx = newtx + rawtx[94:]</div><div class="line"><a name="l00601"></a><span class="lineno"> 601</span>  signresult = node.signrawtransaction(newtx, <span class="keywordtype">None</span>, <span class="keywordtype">None</span>, <span class="stringliteral">"NONE"</span>)</div><div class="line"><a name="l00602"></a><span class="lineno"> 602</span>  txid = node.sendrawtransaction(signresult[<span class="stringliteral">"hex"</span>], <span class="keyword">True</span>)</div><div class="line"><a name="l00603"></a><span class="lineno"> 603</span>  txids.append(txid)</div><div class="line"><a name="l00604"></a><span class="lineno"> 604</span>  <span class="keywordflow">return</span> txids</div><div class="line"><a name="l00605"></a><span class="lineno"> 605</span> </div><div class="line"><a name="l00606"></a><span class="lineno"><a class="line" href="namespacetest__framework_1_1util.html#a0c488722f9c17927249c2e862d9fab32"> 606</a></span> <span class="keyword">def </span><a class="code" href="namespacetest__framework_1_1util.html#a0c488722f9c17927249c2e862d9fab32">get_bip9_status</a>(node, key):</div><div class="line"><a name="l00607"></a><span class="lineno"> 607</span>  info = node.getblockchaininfo()</div><div class="line"><a name="l00608"></a><span class="lineno"> 608</span>  <span class="keywordflow">for</span> row <span class="keywordflow">in</span> info[<span class="stringliteral">'bip9_softforks'</span>]:</div><div class="line"><a name="l00609"></a><span class="lineno"> 609</span>  <span class="keywordflow">if</span> row[<span class="stringliteral">'id'</span>] == key:</div><div class="line"><a name="l00610"></a><span class="lineno"> 610</span>  <span class="keywordflow">return</span> row</div><div class="line"><a name="l00611"></a><span class="lineno"> 611</span>  <span class="keywordflow">raise</span> IndexError (<span class="stringliteral">'key:"%s" not found'</span> % key)</div><div class="ttc" id="namespacetest__framework_1_1util_html_a9e0ced9f6fa4bdbcfcd6e52363cfba74"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a9e0ced9f6fa4bdbcfcd6e52363cfba74">test_framework.util.wait_bitcoinds</a></div><div class="ttdeci">def wait_bitcoinds()</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00337">util.py:337</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a014ebe32f938d2f22cc54592a9eaffca"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a014ebe32f938d2f22cc54592a9eaffca">test_framework.util.check_json_precision</a></div><div class="ttdeci">def check_json_precision()</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00098">util.py:98</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_adf11fca732419a7289c9d119119b34f2"><div class="ttname"><a href="namespacetest__framework_1_1util.html#adf11fca732419a7289c9d119119b34f2">test_framework.util.get_rpc_proxy</a></div><div class="ttdeci">def get_rpc_proxy(url, node_number, timeout=None)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00058">util.py:58</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a4176bf733648642a46bbc3e14438f441"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a4176bf733648642a46bbc3e14438f441">test_framework.util.get_mocktime</a></div><div class="ttdeci">def get_mocktime()</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00049">util.py:49</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a8571fcee33420f02c7703f938ebfe545"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a8571fcee33420f02c7703f938ebfe545">test_framework.util.initialize_chain</a></div><div class="ttdeci">def initialize_chain(test_dir)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00184">util.py:184</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a0c488722f9c17927249c2e862d9fab32"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a0c488722f9c17927249c2e862d9fab32">test_framework.util.get_bip9_status</a></div><div class="ttdeci">def get_bip9_status(node, key)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00606">util.py:606</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a2060906ea1bd7e3032ad3718160f28fd"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a2060906ea1bd7e3032ad3718160f28fd">test_framework.util.random_transaction</a></div><div class="ttdeci">def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00442">util.py:442</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a3e374173222041b2ca3ec9b06993d62f"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a3e374173222041b2ca3ec9b06993d62f">test_framework.util.count_bytes</a></div><div class="ttdeci">def count_bytes(hex_string)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00105">util.py:105</a></div></div>
|
|
<div class="ttc" id="classtest__framework_1_1authproxy_1_1AuthServiceProxy_html"><div class="ttname"><a href="classtest__framework_1_1authproxy_1_1AuthServiceProxy.html">test_framework.authproxy.AuthServiceProxy</a></div><div class="ttdef"><b>Definition:</b> <a href="authproxy_8py_source.html#l00067">authproxy.py:67</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a7a98a073cd2a7a26b707f52d2fef01be"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a7a98a073cd2a7a26b707f52d2fef01be">test_framework.util.hex_str_to_bytes</a></div><div class="ttdeci">def hex_str_to_bytes(hex_str)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00111">util.py:111</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a2ffb3a7be720230b0e302867296bd893"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a2ffb3a7be720230b0e302867296bd893">test_framework.util.assert_array_result</a></div><div class="ttdeci">def assert_array_result(object_array, to_match, expected, should_not_find=False)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00496">util.py:496</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a38c565d0ecd75410e6fb90126c743482"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a38c565d0ecd75410e6fb90126c743482">test_framework.util.assert_greater_than</a></div><div class="ttdeci">def assert_greater_than(thing1, thing2)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00465">util.py:465</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_aa6b84bae918a356af030860efab10362"><div class="ttname"><a href="namespacetest__framework_1_1util.html#aa6b84bae918a356af030860efab10362">test_framework.util.start_nodes</a></div><div class="ttdeci">def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00305">util.py:305</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a0c2ac88b78189fa2112558f2b3281b98"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a0c2ac88b78189fa2112558f2b3281b98">test_framework.util.assert_raises</a></div><div class="ttdeci">def assert_raises(exc, fun, args, kwds)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00469">util.py:469</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a6cfe71893f4a2ba2e7f30d87c615a322"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a6cfe71893f4a2ba2e7f30d87c615a322">test_framework.util.wait_to_sync</a></div><div class="ttdeci">def wait_to_sync(node)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00087">util.py:87</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a43f0c78d2371ed5dd82720572493fc09"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a43f0c78d2371ed5dd82720572493fc09">test_framework.util.disable_mocktime</a></div><div class="ttdeci">def disable_mocktime()</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00045">util.py:45</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a1b05b9466611848d89d6abac1826fe66"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a1b05b9466611848d89d6abac1826fe66">test_framework.util.make_change</a></div><div class="ttdeci">def make_change(from_node, amount_in, amount_out, fee)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00384">util.py:384</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_aa1eacfbd44ba6019d659733acf4b1a71"><div class="ttname"><a href="namespacetest__framework_1_1util.html#aa1eacfbd44ba6019d659733acf4b1a71">test_framework.util.connect_nodes</a></div><div class="ttdeci">def connect_nodes(from_connection, node_num)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00343">util.py:343</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a7564b2d8364eadc29117e34d1cd00ad4"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a7564b2d8364eadc29117e34d1cd00ad4">test_framework.util.sync_mempools</a></div><div class="ttdeci">def sync_mempools(rpc_connections, wait=1)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00127">util.py:127</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a2f920625c10176f344e857eea15e75b4"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a2f920625c10176f344e857eea15e75b4">test_framework.util.sync_masternodes</a></div><div class="ttdeci">def sync_masternodes(rpc_connections)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00142">util.py:142</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ae3437fca5527c14df602a532e66e0076"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ae3437fca5527c14df602a532e66e0076">test_framework.util.send_zeropri_transaction</a></div><div class="ttdeci">def send_zeropri_transaction(from_node, to_node, amount, fee)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00401">util.py:401</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ad6740628a03c98f11b891be7f27741df"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ad6740628a03c98f11b891be7f27741df">test_framework.util.get_mnsync_status</a></div><div class="ttdeci">def get_mnsync_status(node)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00083">util.py:83</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a016b1065dcfa9d79ebdb1b56d721c3ba"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a016b1065dcfa9d79ebdb1b56d721c3ba">test_framework.util.rpc_url</a></div><div class="ttdeci">def rpc_url(i, rpchost=None)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00161">util.py:161</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_af641a75ac322987542583d7b2222c25a"><div class="ttname"><a href="namespacetest__framework_1_1util.html#af641a75ac322987542583d7b2222c25a">test_framework.util.enable_mocktime</a></div><div class="ttdeci">def enable_mocktime()</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00038">util.py:38</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a0d5c2187844d0b046113dbea6b956413"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a0d5c2187844d0b046113dbea6b956413">test_framework.util.initialize_chain_clean</a></div><div class="ttdeci">def initialize_chain_clean(test_dir, num_nodes)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00252">util.py:252</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a48dd2950941d1a9c5651343b7e894e49"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a48dd2950941d1a9c5651343b7e894e49">test_framework.util.find_output</a></div><div class="ttdeci">def find_output(node, txid, amount)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00355">util.py:355</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a2d6cbb1015ca6a97273de4dcf5be900c"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a2d6cbb1015ca6a97273de4dcf5be900c">test_framework.util.satoshi_round</a></div><div class="ttdeci">def satoshi_round(amount)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00525">util.py:525</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_add8e7b0a77dddd68bdb4bd3514f58da6"><div class="ttname"><a href="namespacetest__framework_1_1util.html#add8e7b0a77dddd68bdb4bd3514f58da6">test_framework.util.gather_inputs</a></div><div class="ttdeci">def gather_inputs(from_node, amount_needed, confirmations_required=1)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00367">util.py:367</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a5a904f1d65ae6c90ce714e2667565785"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a5a904f1d65ae6c90ce714e2667565785">test_framework.util.random_zeropri_transaction</a></div><div class="ttdeci">def random_zeropri_transaction(nodes, amount, min_fee, fee_increment, fee_variants)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00431">util.py:431</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a9666cce08677f16638efd2207c3855e2"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a9666cce08677f16638efd2207c3855e2">test_framework.util.create_tx</a></div><div class="ttdeci">def create_tx(node, coinbase, to_address, amount)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00577">util.py:577</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ab86494439dc4a3b58f808c6b9897930c"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ab86494439dc4a3b58f808c6b9897930c">test_framework.util.stop_nodes</a></div><div class="ttdeci">def stop_nodes(nodes)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00328">util.py:328</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a8fc6d48b2e47cf4a444310feff09ca5a"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a8fc6d48b2e47cf4a444310feff09ca5a">test_framework.util.gen_return_txouts</a></div><div class="ttdeci">def gen_return_txouts()</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00559">util.py:559</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a6750da97ae214f27a180d67ed8c7fb37"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a6750da97ae214f27a180d67ed8c7fb37">test_framework.util.set_node_times</a></div><div class="ttdeci">def set_node_times(nodes, t)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00333">util.py:333</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_aebc7ae4dc3512e677020141c7370b2e1"><div class="ttname"><a href="namespacetest__framework_1_1util.html#aebc7ae4dc3512e677020141c7370b2e1">test_framework.util.start_node</a></div><div class="ttdeci">def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00281">util.py:281</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_adedab36f7b224153aba7cefb50663d3c"><div class="ttname"><a href="namespacetest__framework_1_1util.html#adedab36f7b224153aba7cefb50663d3c">test_framework.util.stop_node</a></div><div class="ttdeci">def stop_node(node, i)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00323">util.py:323</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ab9abe249755797f0498d9f5509aa25b4"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ab9abe249755797f0498d9f5509aa25b4">test_framework.util.assert_is_hex_string</a></div><div class="ttdeci">def assert_is_hex_string(string)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00479">util.py:479</a></div></div>
|
|
<div class="ttc" id="mining_8cpp_html_afc5f2c0cbe40a2f876b46df2929cf359"><div class="ttname"><a href="mining_8cpp.html#afc5f2c0cbe40a2f876b46df2929cf359">generate</a></div><div class="ttdeci">UniValue generate(const UniValue &params, bool fHelp)</div><div class="ttdef"><b>Definition:</b> <a href="mining_8cpp_source.html#l00122">mining.cpp:122</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_aa20567f95203db19bbd3bf531ddabff6"><div class="ttname"><a href="namespacetest__framework_1_1util.html#aa20567f95203db19bbd3bf531ddabff6">test_framework.util.sync_blocks</a></div><div class="ttdeci">def sync_blocks(rpc_connections, wait=1)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00117">util.py:117</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ae9c2671db3d700ac6920b8ee10dcbce1"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ae9c2671db3d700ac6920b8ee10dcbce1">test_framework.util.enable_coverage</a></div><div class="ttdeci">def enable_coverage(dirname)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00052">util.py:52</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_add85a25262bdd7a65a811c3084600158"><div class="ttname"><a href="namespacetest__framework_1_1util.html#add85a25262bdd7a65a811c3084600158">test_framework.util.rpc_port</a></div><div class="ttdeci">def rpc_port(n)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00095">util.py:95</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a239cec5d2c7ebb76bac776573d2fe3ba"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a239cec5d2c7ebb76bac776573d2fe3ba">test_framework.util.wait_for_bitcoind_start</a></div><div class="ttdeci">def wait_for_bitcoind_start(process, url, i)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00164">util.py:164</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a99b643a1d14d908740b1686a55635b5d"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a99b643a1d14d908740b1686a55635b5d">test_framework.util.log_filename</a></div><div class="ttdeci">def log_filename(dirname, n_node, logname)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00320">util.py:320</a></div></div>
|
|
<div class="ttc" id="blockchain_8cpp_html_a44f5bbe5b8c41540712ec39d2ece88a9"><div class="ttname"><a href="blockchain_8cpp.html#a44f5bbe5b8c41540712ec39d2ece88a9">getrawmempool</a></div><div class="ttdeci">UniValue getrawmempool(const UniValue &params, bool fHelp)</div><div class="ttdef"><b>Definition:</b> <a href="blockchain_8cpp_source.html#l00234">blockchain.cpp:234</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ab508713a21d5cb4d5629119aaf1e770b"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ab508713a21d5cb4d5629119aaf1e770b">test_framework.util.initialize_datadir</a></div><div class="ttdeci">def initialize_datadir(dirname, n)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00148">util.py:148</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ad2a1eac247f3595c8d70f05c97edc542"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ad2a1eac247f3595c8d70f05c97edc542">test_framework.util.create_confirmed_utxos</a></div><div class="ttdeci">def create_confirmed_utxos(fee, node, count)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00530">util.py:530</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a42d666cfdf0d62c3e36ba4d9f4026621"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a42d666cfdf0d62c3e36ba4d9f4026621">test_framework.util._rpchost_to_args</a></div><div class="ttdeci">def _rpchost_to_args(rpchost)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00261">util.py:261</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_abb8795de00113ae4bb365c0590fa1aa7"><div class="ttname"><a href="namespacetest__framework_1_1util.html#abb8795de00113ae4bb365c0590fa1aa7">test_framework.util.assert_is_hash_string</a></div><div class="ttdeci">def assert_is_hash_string(string, length=64)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00486">util.py:486</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_aa5bb10ad85ada1af40351b523264e1eb"><div class="ttname"><a href="namespacetest__framework_1_1util.html#aa5bb10ad85ada1af40351b523264e1eb">test_framework.util.str_to_b64str</a></div><div class="ttdeci">def str_to_b64str(string)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00114">util.py:114</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a34ded7a772f1910f8137937a1fb81f86"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">test_framework.util.p2p_port</a></div><div class="ttdeci">def p2p_port(n)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00093">util.py:93</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ad3df488aacbcdc741bbb9eb66caddd6b"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">test_framework.util.assert_equal</a></div><div class="ttdeci">def assert_equal(thing1, thing2)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00461">util.py:461</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_a8284a471708986c9fb9d9b3fc13141ae"><div class="ttname"><a href="namespacetest__framework_1_1util.html#a8284a471708986c9fb9d9b3fc13141ae">test_framework.util.connect_nodes_bi</a></div><div class="ttdeci">def connect_nodes_bi(nodes, a, b)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00351">util.py:351</a></div></div>
|
|
<div class="ttc" id="classtest__framework_1_1coverage_1_1AuthServiceProxyWrapper_html"><div class="ttname"><a href="classtest__framework_1_1coverage_1_1AuthServiceProxyWrapper.html">test_framework.coverage.AuthServiceProxyWrapper</a></div><div class="ttdef"><b>Definition:</b> <a href="coverage_8py_source.html#l00015">coverage.py:15</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_aa4d1ef0eb05b1ea365f163a9c0112e5c"><div class="ttname"><a href="namespacetest__framework_1_1util.html#aa4d1ef0eb05b1ea365f163a9c0112e5c">test_framework.util.create_lots_of_big_transactions</a></div><div class="ttdeci">def create_lots_of_big_transactions(node, txouts, utxos, fee)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00587">util.py:587</a></div></div>
|
|
<div class="ttc" id="namespacetest__framework_1_1util_html_ae6b425a1e3feb505726ee64525523264"><div class="ttname"><a href="namespacetest__framework_1_1util.html#ae6b425a1e3feb505726ee64525523264">test_framework.util.bytes_to_hex_str</a></div><div class="ttdeci">def bytes_to_hex_str(byte_str)</div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00108">util.py:108</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_62ba24d7ce8eecc59962fe5b590c1065.html">qa</a></li><li class="navelem"><a class="el" href="dir_dbddb259b29a77ea11562b7a380aa303.html">rpc-tests</a></li><li class="navelem"><a class="el" href="dir_0f1fd91d0d18a547184c924770390b91.html">test_framework</a></li><li class="navelem"><a class="el" href="util_8py.html">util.py</a></li>
|
|
<li class="footer">Generated on Thu Dec 14 2017 13:15:02 for Dash Core by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|