dash-docs/en/doxygen/html/p2p-acceptblock_8py_source.html

151 lines
75 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/p2p-acceptblock.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&amp;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
&#160;<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&amp;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&amp;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&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('p2p-acceptblock_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">p2p-acceptblock.py</div> </div>
</div><!--header-->
<div class="contents">
<a href="p2p-acceptblock_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="namespacep2p-acceptblock.html"> 1</a></span>&#160;<span class="comment">#!/usr/bin/env python2</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">#</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<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>&#160;<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>&#160;<span class="comment">#</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;</div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="keyword">from</span> <a class="code" href="namespacetest__framework_1_1mininode.html">test_framework.mininode</a> <span class="keyword">import</span> *</div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="keyword">from</span> <a class="code" href="namespacetest__framework_1_1test__framework.html">test_framework.test_framework</a> <span class="keyword">import</span> BitcoinTestFramework</div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="keyword">from</span> <a class="code" href="namespacetest__framework_1_1util.html">test_framework.util</a> <span class="keyword">import</span> *</div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="keyword">import</span> time</div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="keyword">from</span> <a class="code" href="namespacetest__framework_1_1blocktools.html">test_framework.blocktools</a> <span class="keyword">import</span> create_block, create_coinbase</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="stringliteral">&#39;&#39;&#39;</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="stringliteral">AcceptBlockTest -- test processing of unrequested blocks.</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="stringliteral">Since behavior differs when receiving unrequested blocks from whitelisted peers</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="stringliteral">versus non-whitelisted peers, this tests the behavior of both (effectively two</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="stringliteral">separate tests running in parallel).</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="stringliteral">Setup: two nodes, node0 and node1, not connected to each other. Node0 does not</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="stringliteral">whitelist localhost, but node1 does. They will each be on their own chain for</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="stringliteral">this test.</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="stringliteral">We have one NodeConn connection to each, test_node and white_node respectively.</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="stringliteral">The test:</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="stringliteral">1. Generate one block on each node, to leave IBD.</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;<span class="stringliteral">2. Mine a new block on each tip, and deliver to each node from node&#39;s peer.</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="stringliteral"> The tip should advance.</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;<span class="stringliteral">3. Mine a block that forks the previous block, and deliver to each node from</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;<span class="stringliteral"> corresponding peer.</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160;<span class="stringliteral"> Node0 should not process this block (just accept the header), because it is</span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;<span class="stringliteral"> unrequested and doesn&#39;t have more work than the tip.</span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;<span class="stringliteral"> Node1 should process because this is coming from a whitelisted peer.</span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;<span class="stringliteral">4. Send another block that builds on the forking block.</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;<span class="stringliteral"> Node0 should process this block but be stuck on the shorter chain, because</span></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="stringliteral"> it&#39;s missing an intermediate block.</span></div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160;<span class="stringliteral"> Node1 should reorg to this longer chain.</span></div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160;<span class="stringliteral">4b.Send 288 more blocks on the longer chain.</span></div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160;<span class="stringliteral"> Node0 should process all but the last block (too far ahead in height).</span></div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160;<span class="stringliteral"> Send all headers to Node1, and then send the last block in that chain.</span></div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;<span class="stringliteral"> Node1 should accept the block because it&#39;s coming from a whitelisted peer.</span></div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;<span class="stringliteral">5. Send a duplicate of the block in #3 to Node0.</span></div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160;<span class="stringliteral"> Node0 should not process the block because it is unrequested, and stay on</span></div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;<span class="stringliteral"> the shorter chain.</span></div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="stringliteral">6. Send Node0 an inv for the height 3 block produced in #4 above.</span></div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;<span class="stringliteral"> Node0 should figure out that Node0 has the missing height 2 block and send a</span></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;<span class="stringliteral"> getdata.</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160;<span class="stringliteral"></span></div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="stringliteral">7. Send Node0 the missing block again.</span></div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160;<span class="stringliteral"> Node0 should process and the tip should advance.</span></div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160;<span class="stringliteral">&#39;&#39;&#39;</span></div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;<span class="comment"># TestNode: bare-bones &quot;peer&quot;. Used mostly as a conduit for a test to sending</span></div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160;<span class="comment"># p2p messages to a node, generating the messages in the main testing logic.</span></div><div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html"> 62</a></span>&#160;<span class="keyword">class </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html">TestNode</a>(<a class="code" href="classtest__framework_1_1mininode_1_1NodeConnCB.html">NodeConnCB</a>):</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a8e2e1ff1baf2be38695bff20f3a9cd87"> 63</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#a8e2e1ff1baf2be38695bff20f3a9cd87">__init__</a>(self):</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; NodeConnCB.__init__(self)</div><div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a6d1d951f830433d580a692211389bc47"> 65</a></span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a6d1d951f830433d580a692211389bc47">connection</a> = <span class="keywordtype">None</span></div><div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a5628b73f513decb50b9db9a18d600bf4"> 66</a></span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5628b73f513decb50b9db9a18d600bf4">ping_counter</a> = 1</div><div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a5633104b13c44a201f258bc3745b7ee2"> 67</a></span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5633104b13c44a201f258bc3745b7ee2">last_pong</a> = <a class="code" href="classtest__framework_1_1mininode_1_1msg__pong.html">msg_pong</a>()</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160;</div><div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#ac163a787b510d537750dcb8132013987"> 69</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#ac163a787b510d537750dcb8132013987">add_connection</a>(self, conn):</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a6d1d951f830433d580a692211389bc47">connection</a> = conn</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="comment"># Track the last getdata message we receive (used in the test)</span></div><div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a3342dd91c1f82c6c355d81d1dae4e33d"> 73</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#a3342dd91c1f82c6c355d81d1dae4e33d">on_getdata</a>(self, conn, message):</div><div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a4c0135c3bb1d405832ba507501e9ff6e"> 74</a></span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a4c0135c3bb1d405832ba507501e9ff6e">last_getdata</a> = message</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <span class="comment"># Spin until verack message is received from the node.</span></div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="comment"># We use this to signal that our test can begin. This</span></div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; <span class="comment"># is called from the testing thread, so it needs to acquire</span></div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; <span class="comment"># the global lock.</span></div><div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#ab2d4d1aae78da789ff9b4b032baa529b"> 80</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#ab2d4d1aae78da789ff9b4b032baa529b">wait_for_verack</a>(self):</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; <span class="keywordflow">while</span> <span class="keyword">True</span>:</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; with mininode_lock:</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; <span class="keywordflow">if</span> self.<a class="code" href="classtest__framework_1_1mininode_1_1NodeConnCB.html#a6e13b71e42a3a4f00e904f22495c5566">verack_received</a>:</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <span class="keywordflow">return</span></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; time.sleep(0.05)</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; <span class="comment"># Wrapper for the NodeConn&#39;s send_message function</span></div><div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a3f667f6967a973179816fba1c33e5efa"> 88</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#a3f667f6967a973179816fba1c33e5efa">send_message</a>(self, message):</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a6d1d951f830433d580a692211389bc47">connection</a>.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a3f667f6967a973179816fba1c33e5efa">send_message</a>(message)</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160;</div><div class="line"><a name="l00091"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#ac4237efa3c022854bc67b6491ad44975"> 91</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#ac4237efa3c022854bc67b6491ad44975">on_pong</a>(self, conn, message):</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5633104b13c44a201f258bc3745b7ee2">last_pong</a> = message</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160;</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <span class="comment"># Sync up with the node after delivery of a block</span></div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1TestNode.html#a318a7649ab4274a0c7c881cd33bc251f"> 95</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1TestNode.html#a318a7649ab4274a0c7c881cd33bc251f">sync_with_ping</a>(self, timeout=30):</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a6d1d951f830433d580a692211389bc47">connection</a>.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a3f667f6967a973179816fba1c33e5efa">send_message</a>(<a class="code" href="classtest__framework_1_1mininode_1_1msg__ping.html">msg_ping</a>(nonce=self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5628b73f513decb50b9db9a18d600bf4">ping_counter</a>))</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; received_pong = <span class="keyword">False</span></div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; sleep_time = 0.05</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="keywordflow">while</span> <span class="keywordflow">not</span> received_pong <span class="keywordflow">and</span> timeout &gt; 0:</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; time.sleep(sleep_time)</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; timeout -= sleep_time</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; with mininode_lock:</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; <span class="keywordflow">if</span> self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5633104b13c44a201f258bc3745b7ee2">last_pong</a>.nonce == self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5628b73f513decb50b9db9a18d600bf4">ping_counter</a>:</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; received_pong = <span class="keyword">True</span></div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1TestNode.html#a5628b73f513decb50b9db9a18d600bf4">ping_counter</a> += 1</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160; <span class="keywordflow">return</span> received_pong</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160;</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160;</div><div class="line"><a name="l00109"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1AcceptBlockTest.html"> 109</a></span>&#160;<span class="keyword">class </span><a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html">AcceptBlockTest</a>(<a class="code" href="classtest__framework_1_1test__framework_1_1BitcoinTestFramework.html">BitcoinTestFramework</a>):</div><div class="line"><a name="l00110"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1AcceptBlockTest.html#aa0d874808a837c5a5aa94e9b9e3e39c2"> 110</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#aa0d874808a837c5a5aa94e9b9e3e39c2">add_options</a>(self, parser):</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; parser.add_option(<span class="stringliteral">&quot;--testbinary&quot;</span>, dest=<span class="stringliteral">&quot;testbinary&quot;</span>,</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; default=os.getenv(<span class="stringliteral">&quot;DASHD&quot;</span>, <span class="stringliteral">&quot;dashd&quot;</span>),</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; help=<span class="stringliteral">&quot;bitcoind binary to test&quot;</span>)</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160;</div><div class="line"><a name="l00115"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1AcceptBlockTest.html#ae829eae5669bc49d25c11dc3ef0b5f08"> 115</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#ae829eae5669bc49d25c11dc3ef0b5f08">setup_chain</a>(self):</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#a0d5c2187844d0b046113dbea6b956413">initialize_chain_clean</a>(self.options.tmpdir, 2)</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160;</div><div class="line"><a name="l00118"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a46680473b87e94dbd78977b47ddf5857"> 118</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a46680473b87e94dbd78977b47ddf5857">setup_network</a>(self):</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; <span class="comment"># Node0 will be used to test behavior of processing unrequested blocks</span></div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; <span class="comment"># from peers which are not whitelisted, while Node1 will be used for</span></div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; <span class="comment"># the whitelisted case.</span></div><div class="line"><a name="l00122"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a"> 122</a></span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a> = []</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>.append(<a class="code" href="namespacetest__framework_1_1util.html#aebc7ae4dc3512e677020141c7370b2e1">start_node</a>(0, self.options.tmpdir, [<span class="stringliteral">&quot;-debug&quot;</span>],</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; binary=self.options.testbinary))</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>.append(<a class="code" href="namespacetest__framework_1_1util.html#aebc7ae4dc3512e677020141c7370b2e1">start_node</a>(1, self.options.tmpdir,</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; [<span class="stringliteral">&quot;-debug&quot;</span>, <span class="stringliteral">&quot;-whitelist=127.0.0.1&quot;</span>],</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; binary=self.options.testbinary))</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>&#160;</div><div class="line"><a name="l00129"></a><span class="lineno"><a class="line" href="classp2p-acceptblock_1_1AcceptBlockTest.html#abe8bfb306ce52b32388dc084d661e06a"> 129</a></span>&#160; <span class="keyword">def </span><a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#abe8bfb306ce52b32388dc084d661e06a">run_test</a>(self):</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; <span class="comment"># Setup the p2p connections and start up the network thread.</span></div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; test_node = <a class="code" href="classp2p-acceptblock_1_1TestNode.html">TestNode</a>() <span class="comment"># connects to node0 (not whitelisted)</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; white_node = <a class="code" href="classp2p-acceptblock_1_1TestNode.html">TestNode</a>() <span class="comment"># connects to node1 (whitelisted)</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160;</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160; connections = []</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; connections.append(<a class="code" href="classtest__framework_1_1mininode_1_1NodeConn.html">NodeConn</a>(<span class="stringliteral">&#39;127.0.0.1&#39;</span>, <a class="code" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">p2p_port</a>(0), self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0], test_node))</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; connections.append(<a class="code" href="classtest__framework_1_1mininode_1_1NodeConn.html">NodeConn</a>(<span class="stringliteral">&#39;127.0.0.1&#39;</span>, <a class="code" href="namespacetest__framework_1_1util.html#a34ded7a772f1910f8137937a1fb81f86">p2p_port</a>(1), self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[1], white_node))</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; test_node.add_connection(connections[0])</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; white_node.add_connection(connections[1])</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160;</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <a class="code" href="classtest__framework_1_1mininode_1_1NetworkThread.html">NetworkThread</a>().start() <span class="comment"># Start up network handling in another thread</span></div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160;</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; <span class="comment"># Test logic begins here</span></div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; test_node.wait_for_verack()</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; white_node.wait_for_verack()</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; <span class="comment"># 1. Have both nodes mine a block (leave IBD)</span></div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160; [ n.generate(1) <span class="keywordflow">for</span> n <span class="keywordflow">in</span> self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a> ]</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; tips = [ int (<span class="stringliteral">&quot;0x&quot;</span> + n.getbestblockhash() + <span class="stringliteral">&quot;L&quot;</span>, 0) <span class="keywordflow">for</span> n <span class="keywordflow">in</span> self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a> ]</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160;</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; <span class="comment"># 2. Send one block that builds on each tip.</span></div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160; <span class="comment"># This should be accepted.</span></div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160; blocks_h2 = [] <span class="comment"># the height 2 blocks on each node&#39;s chain</span></div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160; block_time = int(time.time()) + 1</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160; <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange(2):</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160; blocks_h2.append(<a class="code" href="namespacetest__framework_1_1blocktools.html#ab3c34a7489e18f5a954a59b06dfcd341">create_block</a>(tips[i], <a class="code" href="namespacetest__framework_1_1blocktools.html#a3fcec92180100b1dcfd1d0f751561081">create_coinbase</a>(2), block_time))</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160; blocks_h2[i].solve()</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160; block_time += 1</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h2[0]))</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160; white_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h2[1]))</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160;</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; [ x.sync_with_ping() <span class="keywordflow">for</span> x <span class="keywordflow">in</span> [test_node, white_node] ]</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="blockchain_8cpp.html#ae0f8b6c1a99fcf8a0e786df27a41a40d">getblockcount</a>(), 2)</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[1].<a class="code" href="blockchain_8cpp.html#ae0f8b6c1a99fcf8a0e786df27a41a40d">getblockcount</a>(), 2)</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;First height 2 block accepted by both nodes&quot;</span></div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160;</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160; <span class="comment"># 3. Send another block that builds on the original tip.</span></div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; blocks_h2f = [] <span class="comment"># Blocks at height 2 that fork off the main chain</span></div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange(2):</div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; blocks_h2f.append(<a class="code" href="namespacetest__framework_1_1blocktools.html#ab3c34a7489e18f5a954a59b06dfcd341">create_block</a>(tips[i], <a class="code" href="namespacetest__framework_1_1blocktools.html#a3fcec92180100b1dcfd1d0f751561081">create_coinbase</a>(2), blocks_h2[i].nTime+1))</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; blocks_h2f[i].solve()</div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h2f[0]))</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; white_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h2f[1]))</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160;</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; [ x.sync_with_ping() <span class="keywordflow">for</span> x <span class="keywordflow">in</span> [test_node, white_node] ]</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160; <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="namespacegetchaintips.html">getchaintips</a>():</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>&#160; <span class="keywordflow">if</span> x[<span class="stringliteral">&#39;hash&#39;</span>] == blocks_h2f[0].hash:</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(x[<span class="stringliteral">&#39;status&#39;</span>], <span class="stringliteral">&quot;headers-only&quot;</span>)</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>&#160;</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>&#160; <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[1].<a class="code" href="namespacegetchaintips.html">getchaintips</a>():</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160; <span class="keywordflow">if</span> x[<span class="stringliteral">&#39;hash&#39;</span>] == blocks_h2f[1].hash:</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(x[<span class="stringliteral">&#39;status&#39;</span>], <span class="stringliteral">&quot;valid-headers&quot;</span>)</div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160;</div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Second height 2 block accepted only from whitelisted peer&quot;</span></div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160;</div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>&#160; <span class="comment"># 4. Now send another block that builds on the forking chain.</span></div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>&#160; blocks_h3 = []</div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span>&#160; <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange(2):</div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span>&#160; blocks_h3.append(<a class="code" href="namespacetest__framework_1_1blocktools.html#ab3c34a7489e18f5a954a59b06dfcd341">create_block</a>(blocks_h2f[i].sha256, <a class="code" href="namespacetest__framework_1_1blocktools.html#a3fcec92180100b1dcfd1d0f751561081">create_coinbase</a>(3), blocks_h2f[i].nTime+1))</div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span>&#160; blocks_h3[i].solve()</div><div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h3[0]))</div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span>&#160; white_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h3[1]))</div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160; [ x.sync_with_ping() <span class="keywordflow">for</span> x <span class="keywordflow">in</span> [test_node, white_node] ]</div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span>&#160; <span class="comment"># Since the earlier block was not processed by node0, the new block</span></div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span>&#160; <span class="comment"># can&#39;t be fully validated.</span></div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span>&#160; <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="namespacegetchaintips.html">getchaintips</a>():</div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>&#160; <span class="keywordflow">if</span> x[<span class="stringliteral">&#39;hash&#39;</span>] == blocks_h3[0].hash:</div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(x[<span class="stringliteral">&#39;status&#39;</span>], <span class="stringliteral">&quot;headers-only&quot;</span>)</div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160;</div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; <span class="comment"># But this block should be accepted by node0 since it has more work.</span></div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; <span class="keywordflow">try</span>:</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="blockchain_8cpp.html#afdd7f5b03a6ab23f3627721b074ef606">getblock</a>(blocks_h3[0].hash)</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Unrequested more-work block accepted from non-whitelisted peer&quot;</span></div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; <span class="keywordflow">except</span>:</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">&quot;Unrequested more work block was not processed&quot;</span>)</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160;</div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; <span class="comment"># Node1 should have accepted and reorged.</span></div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[1].<a class="code" href="blockchain_8cpp.html#ae0f8b6c1a99fcf8a0e786df27a41a40d">getblockcount</a>(), 3)</div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Successfully reorged to length 3 chain from whitelisted peer&quot;</span></div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160;</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; <span class="comment"># 4b. Now mine 288 more blocks and deliver; all should be processed but</span></div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; <span class="comment"># the last (height-too-high) on node0. Node1 should process the tip if</span></div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; <span class="comment"># we give it the headers chain leading to the tip.</span></div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160; tips = blocks_h3</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; headers_message = <a class="code" href="classtest__framework_1_1mininode_1_1msg__headers.html">msg_headers</a>()</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; all_blocks = [] <span class="comment"># node0&#39;s blocks</span></div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; <span class="keywordflow">for</span> j <span class="keywordflow">in</span> xrange(2):</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; <span class="keywordflow">for</span> i <span class="keywordflow">in</span> xrange(288):</div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>&#160; next_block = <a class="code" href="namespacetest__framework_1_1blocktools.html#ab3c34a7489e18f5a954a59b06dfcd341">create_block</a>(tips[j].sha256, <a class="code" href="namespacetest__framework_1_1blocktools.html#a3fcec92180100b1dcfd1d0f751561081">create_coinbase</a>(i + 4), tips[j].nTime+1)</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; next_block.solve()</div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; <span class="keywordflow">if</span> j==0:</div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(next_block))</div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; all_blocks.append(next_block)</div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160; <span class="keywordflow">else</span>:</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160; headers_message.headers.append(<a class="code" href="classtest__framework_1_1mininode_1_1CBlockHeader.html">CBlockHeader</a>(next_block))</div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; tips[j] = next_block</div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160;</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; time.sleep(2)</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160; <span class="keywordflow">for</span> x <span class="keywordflow">in</span> all_blocks:</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span>&#160; <span class="keywordflow">try</span>:</div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="blockchain_8cpp.html#afdd7f5b03a6ab23f3627721b074ef606">getblock</a>(x.hash)</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; <span class="keywordflow">if</span> x == all_blocks[287]:</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">&quot;Unrequested block too far-ahead should have been ignored&quot;</span>)</div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; <span class="keywordflow">except</span>:</div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; <span class="keywordflow">if</span> x == all_blocks[287]:</div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Unrequested block too far-ahead not processed&quot;</span></div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; <span class="keywordflow">else</span>:</div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160; <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">&quot;Unrequested block with more work should have been accepted&quot;</span>)</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160;</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; headers_message.headers.pop() <span class="comment"># Ensure the last block is unrequested</span></div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; white_node.send_message(headers_message) <span class="comment"># Send headers leading to tip</span></div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; white_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(tips[1])) <span class="comment"># Now deliver the tip</span></div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160; <span class="keywordflow">try</span>:</div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; white_node.sync_with_ping()</div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160; self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[1].<a class="code" href="blockchain_8cpp.html#afdd7f5b03a6ab23f3627721b074ef606">getblock</a>(tips[1].hash)</div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Unrequested block far ahead of tip accepted from whitelisted peer&quot;</span></div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160; <span class="keywordflow">except</span>:</div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span>&#160; <span class="keywordflow">raise</span> AssertionError(<span class="stringliteral">&quot;Unrequested block from whitelisted peer not accepted&quot;</span>)</div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span>&#160;</div><div class="line"><a name="l00250"></a><span class="lineno"> 250</span>&#160; <span class="comment"># 5. Test handling of unrequested block on the node that didn&#39;t process</span></div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span>&#160; <span class="comment"># Should still not be processed (even though it has a child that has more</span></div><div class="line"><a name="l00252"></a><span class="lineno"> 252</span>&#160; <span class="comment"># work).</span></div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h2f[0]))</div><div class="line"><a name="l00254"></a><span class="lineno"> 254</span>&#160;</div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160; <span class="comment"># Here, if the sleep is too short, the test could falsely succeed (if the</span></div><div class="line"><a name="l00256"></a><span class="lineno"> 256</span>&#160; <span class="comment"># node hasn&#39;t processed the block by the time the sleep returns, and then</span></div><div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; <span class="comment"># the node processes it and incorrectly advances the tip).</span></div><div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160; <span class="comment"># But this would be caught later on, when we verify that an inv triggers</span></div><div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; <span class="comment"># a getdata request for this block.</span></div><div class="line"><a name="l00260"></a><span class="lineno"> 260</span>&#160; test_node.sync_with_ping()</div><div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="blockchain_8cpp.html#ae0f8b6c1a99fcf8a0e786df27a41a40d">getblockcount</a>(), 2)</div><div class="line"><a name="l00262"></a><span class="lineno"> 262</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Unrequested block that would complete more-work chain was ignored&quot;</span></div><div class="line"><a name="l00263"></a><span class="lineno"> 263</span>&#160;</div><div class="line"><a name="l00264"></a><span class="lineno"> 264</span>&#160; <span class="comment"># 6. Try to get node to request the missing block.</span></div><div class="line"><a name="l00265"></a><span class="lineno"> 265</span>&#160; <span class="comment"># Poke the node with an inv for block at height 3 and see if that</span></div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span>&#160; <span class="comment"># triggers a getdata on block 2 (it should if block 2 is missing).</span></div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span>&#160; with mininode_lock:</div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span>&#160; <span class="comment"># Clear state so we can check the getdata request</span></div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span>&#160; test_node.last_getdata = <span class="keywordtype">None</span></div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__inv.html">msg_inv</a>([<a class="code" href="classtest__framework_1_1mininode_1_1CInv.html">CInv</a>(2, blocks_h3[0].sha256)]))</div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160;</div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160; test_node.sync_with_ping()</div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span>&#160; with mininode_lock:</div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160; getdata = test_node.last_getdata</div><div class="line"><a name="l00275"></a><span class="lineno"> 275</span>&#160;</div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span>&#160; <span class="comment"># Check that the getdata includes the right block</span></div><div class="line"><a name="l00277"></a><span class="lineno"> 277</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(getdata.inv[0].hash, blocks_h2f[0].sha256)</div><div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Inv at tip triggered getdata for unprocessed block&quot;</span></div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160;</div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span>&#160; <span class="comment"># 7. Send the missing block for the third time (now it is requested)</span></div><div class="line"><a name="l00281"></a><span class="lineno"> 281</span>&#160; test_node.send_message(<a class="code" href="classtest__framework_1_1mininode_1_1msg__block.html">msg_block</a>(blocks_h2f[0]))</div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span>&#160;</div><div class="line"><a name="l00283"></a><span class="lineno"> 283</span>&#160; test_node.sync_with_ping()</div><div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160; <a class="code" href="namespacetest__framework_1_1util.html#ad3df488aacbcdc741bbb9eb66caddd6b">assert_equal</a>(self.<a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">nodes</a>[0].<a class="code" href="blockchain_8cpp.html#ae0f8b6c1a99fcf8a0e786df27a41a40d">getblockcount</a>(), 290)</div><div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160; <span class="keywordflow">print</span> <span class="stringliteral">&quot;Successfully reorged to longer chain from non-whitelisted peer&quot;</span></div><div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160;</div><div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160; [ c.disconnect_node() <span class="keywordflow">for</span> c <span class="keywordflow">in</span> connections ]</div><div class="line"><a name="l00288"></a><span class="lineno"> 288</span>&#160;</div><div class="line"><a name="l00289"></a><span class="lineno"> 289</span>&#160;<span class="keywordflow">if</span> __name__ == <span class="stringliteral">&#39;__main__&#39;</span>:</div><div class="line"><a name="l00290"></a><span class="lineno"> 290</span>&#160; <a class="code" href="classp2p-acceptblock_1_1AcceptBlockTest.html">AcceptBlockTest</a>().<a class="code" href="classtest__framework_1_1test__framework_1_1BitcoinTestFramework.html#a076857f5499c37bacf64a8ccb6ba5197">main</a>()</div><div class="ttc" id="namespacetest__framework_1_1blocktools_html_ab3c34a7489e18f5a954a59b06dfcd341"><div class="ttname"><a href="namespacetest__framework_1_1blocktools.html#ab3c34a7489e18f5a954a59b06dfcd341">test_framework.blocktools.create_block</a></div><div class="ttdeci">def create_block(hashprev, coinbase, nTime=None)</div><div class="ttdef"><b>Definition:</b> <a href="blocktools_8py_source.html#l00011">blocktools.py:11</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a3f667f6967a973179816fba1c33e5efa"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a3f667f6967a973179816fba1c33e5efa">p2p-acceptblock.TestNode.send_message</a></div><div class="ttdeci">def send_message(self, message)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00088">p2p-acceptblock.py:88</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1NodeConnCB_html_a6e13b71e42a3a4f00e904f22495c5566"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1NodeConnCB.html#a6e13b71e42a3a4f00e904f22495c5566">test_framework.mininode.NodeConnCB.verack_received</a></div><div class="ttdeci">verack_received</div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l01038">mininode.py:1038</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1AcceptBlockTest_html_abe8bfb306ce52b32388dc084d661e06a"><div class="ttname"><a href="classp2p-acceptblock_1_1AcceptBlockTest.html#abe8bfb306ce52b32388dc084d661e06a">p2p-acceptblock.AcceptBlockTest.run_test</a></div><div class="ttdeci">def run_test(self)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00129">p2p-acceptblock.py:129</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1AcceptBlockTest_html_aa0d874808a837c5a5aa94e9b9e3e39c2"><div class="ttname"><a href="classp2p-acceptblock_1_1AcceptBlockTest.html#aa0d874808a837c5a5aa94e9b9e3e39c2">p2p-acceptblock.AcceptBlockTest.add_options</a></div><div class="ttdeci">def add_options(self, parser)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00110">p2p-acceptblock.py:110</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a8e2e1ff1baf2be38695bff20f3a9cd87"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a8e2e1ff1baf2be38695bff20f3a9cd87">p2p-acceptblock.TestNode.__init__</a></div><div class="ttdeci">def __init__(self)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00063">p2p-acceptblock.py:63</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a6d1d951f830433d580a692211389bc47"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a6d1d951f830433d580a692211389bc47">p2p-acceptblock.TestNode.connection</a></div><div class="ttdeci">connection</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00065">p2p-acceptblock.py:65</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1CInv_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1CInv.html">test_framework.mininode.CInv</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00278">mininode.py:278</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1CBlockHeader_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1CBlockHeader.html">test_framework.mininode.CBlockHeader</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00445">mininode.py:445</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1AcceptBlockTest_html_ae829eae5669bc49d25c11dc3ef0b5f08"><div class="ttname"><a href="classp2p-acceptblock_1_1AcceptBlockTest.html#ae829eae5669bc49d25c11dc3ef0b5f08">p2p-acceptblock.AcceptBlockTest.setup_chain</a></div><div class="ttdeci">def setup_chain(self)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00115">p2p-acceptblock.py:115</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a5628b73f513decb50b9db9a18d600bf4"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a5628b73f513decb50b9db9a18d600bf4">p2p-acceptblock.TestNode.ping_counter</a></div><div class="ttdeci">ping_counter</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00066">p2p-acceptblock.py:66</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a3342dd91c1f82c6c355d81d1dae4e33d"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a3342dd91c1f82c6c355d81d1dae4e33d">p2p-acceptblock.TestNode.on_getdata</a></div><div class="ttdeci">def on_getdata(self, conn, message)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00073">p2p-acceptblock.py:73</a></div></div>
<div class="ttc" id="namespacegetchaintips_html"><div class="ttname"><a href="namespacegetchaintips.html">getchaintips</a></div><div class="ttdef"><b>Definition:</b> <a href="getchaintips_8py_source.html#l00001">getchaintips.py:1</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a5633104b13c44a201f258bc3745b7ee2"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a5633104b13c44a201f258bc3745b7ee2">p2p-acceptblock.TestNode.last_pong</a></div><div class="ttdeci">last_pong</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00067">p2p-acceptblock.py:67</a></div></div>
<div class="ttc" id="blockchain_8cpp_html_afdd7f5b03a6ab23f3627721b074ef606"><div class="ttname"><a href="blockchain_8cpp.html#afdd7f5b03a6ab23f3627721b074ef606">getblock</a></div><div class="ttdeci">UniValue getblock(const UniValue &amp;params, bool fHelp)</div><div class="ttdef"><b>Definition:</b> <a href="blockchain_8cpp_source.html#l00483">blockchain.cpp:483</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1msg__ping_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1msg__ping.html">test_framework.mininode.msg_ping</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00873">mininode.py:873</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1msg__pong_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1msg__pong.html">test_framework.mininode.msg_pong</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00891">mininode.py:891</a></div></div>
<div class="ttc" id="namespacetest__framework_1_1blocktools_html"><div class="ttname"><a href="namespacetest__framework_1_1blocktools.html">test_framework.blocktools</a></div><div class="ttdef"><b>Definition:</b> <a href="blocktools_8py_source.html#l00001">blocktools.py:1</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1NetworkThread_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1NetworkThread.html">test_framework.mininode.NetworkThread</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l01316">mininode.py:1316</a></div></div>
<div class="ttc" id="namespacetest__framework_1_1test__framework_html"><div class="ttname"><a href="namespacetest__framework_1_1test__framework.html">test_framework.test_framework</a></div><div class="ttdef"><b>Definition:</b> <a href="test__framework_8py_source.html#l00001">test_framework.py:1</a></div></div>
<div class="ttc" id="classtest__framework_1_1test__framework_1_1BitcoinTestFramework_html"><div class="ttname"><a href="classtest__framework_1_1test__framework_1_1BitcoinTestFramework.html">test_framework.test_framework.BitcoinTestFramework</a></div><div class="ttdef"><b>Definition:</b> <a href="test__framework_8py_source.html#l00032">test_framework.py:32</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html">p2p-acceptblock.TestNode</a></div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00062">p2p-acceptblock.py:62</a></div></div>
<div class="ttc" id="namespacetest__framework_1_1blocktools_html_a3fcec92180100b1dcfd1d0f751561081"><div class="ttname"><a href="namespacetest__framework_1_1blocktools.html#a3fcec92180100b1dcfd1d0f751561081">test_framework.blocktools.create_coinbase</a></div><div class="ttdeci">def create_coinbase(height, pubkey=None)</div><div class="ttdef"><b>Definition:</b> <a href="blocktools_8py_source.html#l00043">blocktools.py:43</a></div></div>
<div class="ttc" id="blockchain_8cpp_html_ae0f8b6c1a99fcf8a0e786df27a41a40d"><div class="ttname"><a href="blockchain_8cpp.html#ae0f8b6c1a99fcf8a0e786df27a41a40d">getblockcount</a></div><div class="ttdeci">UniValue getblockcount(const UniValue &amp;params, bool fHelp)</div><div class="ttdef"><b>Definition:</b> <a href="blockchain_8cpp_source.html#l00131">blockchain.cpp:131</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="classp2p-acceptblock_1_1TestNode_html_a318a7649ab4274a0c7c881cd33bc251f"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a318a7649ab4274a0c7c881cd33bc251f">p2p-acceptblock.TestNode.sync_with_ping</a></div><div class="ttdeci">def sync_with_ping(self, timeout=30)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00095">p2p-acceptblock.py:95</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1msg__inv_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1msg__inv.html">test_framework.mininode.msg_inv</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00748">mininode.py:748</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1AcceptBlockTest_html_a46680473b87e94dbd78977b47ddf5857"><div class="ttname"><a href="classp2p-acceptblock_1_1AcceptBlockTest.html#a46680473b87e94dbd78977b47ddf5857">p2p-acceptblock.AcceptBlockTest.setup_network</a></div><div class="ttdeci">def setup_network(self)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00118">p2p-acceptblock.py:118</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1NodeConn_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1NodeConn.html">test_framework.mininode.NodeConn</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l01139">mininode.py:1139</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1AcceptBlockTest_html_a68146e26560e7a2da9fa16ab41b8ba0a"><div class="ttname"><a href="classp2p-acceptblock_1_1AcceptBlockTest.html#a68146e26560e7a2da9fa16ab41b8ba0a">p2p-acceptblock.AcceptBlockTest.nodes</a></div><div class="ttdeci">nodes</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00122">p2p-acceptblock.py:122</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_a4c0135c3bb1d405832ba507501e9ff6e"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#a4c0135c3bb1d405832ba507501e9ff6e">p2p-acceptblock.TestNode.last_getdata</a></div><div class="ttdeci">last_getdata</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00074">p2p-acceptblock.py:74</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="classp2p-acceptblock_1_1TestNode_html_ac4237efa3c022854bc67b6491ad44975"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#ac4237efa3c022854bc67b6491ad44975">p2p-acceptblock.TestNode.on_pong</a></div><div class="ttdeci">def on_pong(self, conn, message)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00091">p2p-acceptblock.py:91</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_ab2d4d1aae78da789ff9b4b032baa529b"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#ab2d4d1aae78da789ff9b4b032baa529b">p2p-acceptblock.TestNode.wait_for_verack</a></div><div class="ttdeci">def wait_for_verack(self)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00080">p2p-acceptblock.py:80</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1NodeConnCB_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1NodeConnCB.html">test_framework.mininode.NodeConnCB</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l01036">mininode.py:1036</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1AcceptBlockTest_html"><div class="ttname"><a href="classp2p-acceptblock_1_1AcceptBlockTest.html">p2p-acceptblock.AcceptBlockTest</a></div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00109">p2p-acceptblock.py:109</a></div></div>
<div class="ttc" id="classtest__framework_1_1test__framework_1_1BitcoinTestFramework_html_a076857f5499c37bacf64a8ccb6ba5197"><div class="ttname"><a href="classtest__framework_1_1test__framework_1_1BitcoinTestFramework.html#a076857f5499c37bacf64a8ccb6ba5197">test_framework.test_framework.BitcoinTestFramework.main</a></div><div class="ttdeci">def main(self)</div><div class="ttdef"><b>Definition:</b> <a href="test__framework_8py_source.html#l00097">test_framework.py:97</a></div></div>
<div class="ttc" id="classp2p-acceptblock_1_1TestNode_html_ac163a787b510d537750dcb8132013987"><div class="ttname"><a href="classp2p-acceptblock_1_1TestNode.html#ac163a787b510d537750dcb8132013987">p2p-acceptblock.TestNode.add_connection</a></div><div class="ttdeci">def add_connection(self, conn)</div><div class="ttdef"><b>Definition:</b> <a href="p2p-acceptblock_8py_source.html#l00069">p2p-acceptblock.py:69</a></div></div>
<div class="ttc" id="namespacetest__framework_1_1mininode_html"><div class="ttname"><a href="namespacetest__framework_1_1mininode.html">test_framework.mininode</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00001">mininode.py:1</a></div></div>
<div class="ttc" id="namespacetest__framework_1_1util_html"><div class="ttname"><a href="namespacetest__framework_1_1util.html">test_framework.util</a></div><div class="ttdef"><b>Definition:</b> <a href="util_8py_source.html#l00001">util.py:1</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="classtest__framework_1_1mininode_1_1msg__block_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1msg__block.html">test_framework.mininode.msg_block</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00822">mininode.py:822</a></div></div>
<div class="ttc" id="classtest__framework_1_1mininode_1_1msg__headers_html"><div class="ttname"><a href="classtest__framework_1_1mininode_1_1msg__headers.html">test_framework.mininode.msg_headers</a></div><div class="ttdef"><b>Definition:</b> <a href="mininode_8py_source.html#l00968">mininode.py:968</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="p2p-acceptblock_8py.html">p2p-acceptblock.py</a></li>
<li class="footer">Generated on Thu Dec 14 2017 13:15:01 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>