25
25
26
26
class MnehfTest (DashTestFramework ):
27
27
def set_test_params (self ):
28
- extra_args = [["-vbparams=testdummy:0:999999999999:12:12:12:5:0" ] for _ in range (4 )]
28
+ extra_args = [["-vbparams=testdummy:0:999999999999:12:12:12:5:0" , "-persistmempool=0" ] for _ in range (4 )]
29
29
self .set_dash_test_params (4 , 3 , fast_dip3_enforcement = True , extra_args = extra_args )
30
30
31
31
def skip_test_if_missing_module (self ):
@@ -164,14 +164,12 @@ def run_test(self):
164
164
ehf_tx_sent = self .send_tx (ehf_tx )
165
165
ehf_unknown_tx_sent = self .send_tx (ehf_unknown_tx )
166
166
self .send_tx (ehf_invalid_tx , expected_error = 'bad-mnhf-non-ehf' )
167
- node .generate (1 )
168
- ehf_height = node .getblockcount ()
167
+ ehf_blockhash = node .generate (1 )[0 ]
169
168
self .sync_all ()
170
169
171
- ehf_block = node .getbestblockhash ()
172
- self .log .info (f"Check MnEhfTx { ehf_tx_sent } was mined in { ehf_block } " )
173
- assert ehf_tx_sent in node .getblock (ehf_block )['tx' ]
174
- assert ehf_unknown_tx_sent in node .getblock (ehf_block )['tx' ]
170
+ self .log .info (f"Check MnEhfTx { ehf_tx_sent } was mined in { ehf_blockhash } " )
171
+ assert ehf_tx_sent in node .getblock (ehf_blockhash )['tx' ]
172
+ assert ehf_unknown_tx_sent in node .getblock (ehf_blockhash )['tx' ]
175
173
176
174
self .log .info (f"MnEhf tx: '{ ehf_tx } ' is sent: { ehf_tx_sent } " )
177
175
self .log .info (f"MnEhf 'unknown' tx: '{ ehf_unknown_tx } ' is sent: { ehf_unknown_tx_sent } " )
@@ -201,10 +199,10 @@ def run_test(self):
201
199
202
200
self .check_fork ('active' )
203
201
204
- block_fork_active = node .getbestblockhash ()
205
- self .log .info (f"Invalidate block: { ehf_block } with tip { block_fork_active } " )
202
+ fork_active_blockhash = node .getbestblockhash ()
203
+ self .log .info (f"Invalidate block: { ehf_blockhash } with tip { fork_active_blockhash } " )
206
204
for inode in self .nodes :
207
- inode .invalidateblock (ehf_block )
205
+ inode .invalidateblock (ehf_blockhash )
208
206
209
207
self .log .info ("Expecting for fork to be defined in next blocks because no MnEHF tx here" )
210
208
for i in range (12 ):
@@ -215,12 +213,11 @@ def run_test(self):
215
213
216
214
self .log .info ("Re-sending MnEHF for new fork" )
217
215
tx_sent_2 = self .send_tx (ehf_tx )
218
- node .generate (1 )
216
+ ehf_blockhash_2 = node .generate (1 )[ 0 ]
219
217
self .sync_all ()
220
218
221
- ehf_block_2 = node .getbestblockhash ()
222
- self .log .info (f"Check MnEhfTx again { tx_sent_2 } was mined in { ehf_block_2 } " )
223
- assert tx_sent_2 in node .getblock (ehf_block_2 )['tx' ]
219
+ self .log .info (f"Check MnEhfTx again { tx_sent_2 } was mined in { ehf_blockhash_2 } " )
220
+ assert tx_sent_2 in node .getblock (ehf_blockhash_2 )['tx' ]
224
221
225
222
self .log .info (f"Generate some more block to jump to `started` status" )
226
223
for i in range (12 ):
@@ -230,42 +227,43 @@ def run_test(self):
230
227
self .check_fork ('started' )
231
228
232
229
233
- self .log .info (f"Re-consider block { ehf_block } to the old MnEHF and forget new fork" )
230
+ self .log .info (f"Re-consider block { ehf_blockhash } to the old MnEHF and forget new fork" )
234
231
for inode in self .nodes :
235
- inode .reconsiderblock (ehf_block )
236
- assert_equal (node .getbestblockhash (), block_fork_active )
232
+ inode .reconsiderblock (ehf_blockhash )
233
+ assert_equal (node .getbestblockhash (), fork_active_blockhash )
237
234
238
235
self .check_fork ('active' )
239
236
self .restart_all_nodes ()
240
237
self .check_fork ('active' )
241
238
239
+ self .log .info ("Testing duplicate EHF signal with same bit" )
240
+ ehf_tx_duplicate = self .send_tx (self .create_mnehf (28 , pubkey ))
241
+ tip_blockhash = node .generate (1 )[0 ]
242
+ self .sync_blocks ()
243
+ block = node .getblock (tip_blockhash )
244
+ assert ehf_tx_duplicate in node .getrawmempool () and ehf_tx_duplicate not in block ['tx' ]
245
+
246
+ self .log .info ("Testing EHF signal with same bit but with newer start time" )
242
247
self .bump_mocktime (int (60 * 60 * 24 * 14 ))
243
248
node .generate (1 )
244
- self .sync_all ()
249
+ self .sync_blocks ()
245
250
self .restart_all_nodes (params = [self .mocktime , self .mocktime + 1000000 ])
246
251
self .mine_quorum ()
247
252
248
- ehf_tx_second = self .create_mnehf (28 , pubkey )
249
- assert_equal ( get_bip9_details ( node , 'testdummy' )[ 'status' ], 'defined' )
253
+ ehf_tx_new_start = self .create_mnehf (28 , pubkey )
254
+ self . check_fork ( 'defined' )
250
255
251
- self .log .info ("Testing EHF signal with same bit" )
252
- self .log .info (f"Previous signal at height={ ehf_height } , total blocks={ node .getblockcount ()} , should success at { ehf_height + 576 } " )
253
- self .slowly_generate_batch (576 - (node .getblockcount () - ehf_height ) - 1 )
254
- ehf_tx_sent = self .send_tx (ehf_tx_second )
255
- self .log .info ("Mine block and ensure not mined yet..." )
256
- node .generate (1 )
257
- self .ensure_tx_is_not_mined (ehf_tx_sent )
258
- node .generate (1 )
256
+ self .log .info ("Mine one block and ensure EHF tx for the new deployment is mined" )
257
+ ehf_tx_sent = self .send_tx (ehf_tx_new_start )
258
+ tip_blockhash = node .generate (1 )[0 ]
259
259
self .sync_all ()
260
- self .log .info ("Mine one more block and ensure it is mined" )
261
- block = node .getblock (node .getbestblockhash ())
260
+ block = node .getblock (tip_blockhash )
262
261
assert ehf_tx_sent in block ['tx' ]
263
262
264
263
self .check_fork ('defined' )
265
264
self .slowly_generate_batch (12 * 4 )
266
265
self .check_fork ('active' )
267
266
268
267
269
-
270
268
if __name__ == '__main__' :
271
269
MnehfTest ().main ()
0 commit comments