@@ -83,8 +83,6 @@ def send_blocks_until_disconnected(self, p2p_conn):
8383 break
8484
8585 def run_test (self ):
86- p2p0 = self .nodes [0 ].add_p2p_connection (BaseNode ())
87-
8886 # Build the blockchain
8987 self .tip = int (self .nodes [0 ].getbestblockhash (), 16 )
9088 self .block_time = self .nodes [0 ].getblock (self .nodes [0 ].getbestblockhash ())['time' ] + 1
@@ -139,35 +137,33 @@ def run_test(self):
139137 self .block_time += 1
140138 height += 1
141139
142- self .nodes [0 ].disconnect_p2ps ()
143-
144140 # Start node1 and node2 with assumevalid so they accept a block with a bad signature.
145141 self .start_node (1 , extra_args = ["-assumevalid=" + hex (block102 .sha256 )])
146142 self .start_node (2 , extra_args = ["-assumevalid=" + hex (block102 .sha256 )])
147143
148144 p2p0 = self .nodes [0 ].add_p2p_connection (BaseNode ())
149- p2p1 = self .nodes [1 ].add_p2p_connection (BaseNode ())
150- p2p2 = self .nodes [2 ].add_p2p_connection (BaseNode ())
151-
152- # send header lists to all three nodes
153145 p2p0 .send_header_for_blocks (self .blocks [0 :2000 ])
154146 p2p0 .send_header_for_blocks (self .blocks [2000 :])
155- p2p1 .send_header_for_blocks (self .blocks [0 :2000 ])
156- p2p1 .send_header_for_blocks (self .blocks [2000 :])
157- p2p2 .send_header_for_blocks (self .blocks [0 :200 ])
158147
159148 # Send blocks to node0. Block 102 will be rejected.
160149 self .send_blocks_until_disconnected (p2p0 )
161150 self .wait_until (lambda : self .nodes [0 ].getblockcount () >= COINBASE_MATURITY + 1 )
162151 assert_equal (self .nodes [0 ].getblockcount (), COINBASE_MATURITY + 1 )
163152
153+ p2p1 = self .nodes [1 ].add_p2p_connection (BaseNode ())
154+ p2p1 .send_header_for_blocks (self .blocks [0 :2000 ])
155+ p2p1 .send_header_for_blocks (self .blocks [2000 :])
156+
164157 # Send all blocks to node1. All blocks will be accepted.
165158 for i in range (2202 ):
166159 p2p1 .send_message (msg_block (self .blocks [i ]))
167160 # Syncing 2200 blocks can take a while on slow systems. Give it plenty of time to sync.
168161 p2p1 .sync_with_ping (960 )
169162 assert_equal (self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['height' ], 2202 )
170163
164+ p2p2 = self .nodes [2 ].add_p2p_connection (BaseNode ())
165+ p2p2 .send_header_for_blocks (self .blocks [0 :200 ])
166+
171167 # Send blocks to node2. Block 102 will be rejected.
172168 self .send_blocks_until_disconnected (p2p2 )
173169 self .wait_until (lambda : self .nodes [2 ].getblockcount () >= COINBASE_MATURITY + 1 )
0 commit comments