@@ -83,8 +83,6 @@ def send_blocks_until_disconnected(self, p2p_conn):
83
83
break
84
84
85
85
def run_test (self ):
86
- p2p0 = self .nodes [0 ].add_p2p_connection (BaseNode ())
87
-
88
86
# Build the blockchain
89
87
self .tip = int (self .nodes [0 ].getbestblockhash (), 16 )
90
88
self .block_time = self .nodes [0 ].getblock (self .nodes [0 ].getbestblockhash ())['time' ] + 1
@@ -139,35 +137,33 @@ def run_test(self):
139
137
self .block_time += 1
140
138
height += 1
141
139
142
- self .nodes [0 ].disconnect_p2ps ()
143
-
144
140
# Start node1 and node2 with assumevalid so they accept a block with a bad signature.
145
141
self .start_node (1 , extra_args = ["-assumevalid=" + hex (block102 .sha256 )])
146
142
self .start_node (2 , extra_args = ["-assumevalid=" + hex (block102 .sha256 )])
147
143
148
144
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
153
145
p2p0 .send_header_for_blocks (self .blocks [0 :2000 ])
154
146
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 ])
158
147
159
148
# Send blocks to node0. Block 102 will be rejected.
160
149
self .send_blocks_until_disconnected (p2p0 )
161
150
self .wait_until (lambda : self .nodes [0 ].getblockcount () >= COINBASE_MATURITY + 1 )
162
151
assert_equal (self .nodes [0 ].getblockcount (), COINBASE_MATURITY + 1 )
163
152
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
+
164
157
# Send all blocks to node1. All blocks will be accepted.
165
158
for i in range (2202 ):
166
159
p2p1 .send_message (msg_block (self .blocks [i ]))
167
160
# Syncing 2200 blocks can take a while on slow systems. Give it plenty of time to sync.
168
161
p2p1 .sync_with_ping (960 )
169
162
assert_equal (self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['height' ], 2202 )
170
163
164
+ p2p2 = self .nodes [2 ].add_p2p_connection (BaseNode ())
165
+ p2p2 .send_header_for_blocks (self .blocks [0 :200 ])
166
+
171
167
# Send blocks to node2. Block 102 will be rejected.
172
168
self .send_blocks_until_disconnected (p2p2 )
173
169
self .wait_until (lambda : self .nodes [2 ].getblockcount () >= COINBASE_MATURITY + 1 )
0 commit comments