@@ -32,39 +32,43 @@ def skip_test_if_missing_module(self):
32
32
self .skip_if_no_wallet ()
33
33
34
34
def run_test (self ):
35
- self .nodes [0 ].add_p2p_connection (P2PStoreTxInvs ())
35
+ node = self .nodes [0 ]
36
+ node .add_p2p_connection (P2PStoreTxInvs ())
36
37
37
38
# Create a new transaction. Set time to 31 minutes in the past.
38
- time_now = int (time .time ())
39
- self .nodes [0 ].setmocktime (time_now - 60 * 31 )
40
- txid = self .nodes [0 ].sendtoaddress (self .nodes [0 ].getnewaddress (), 1 )
39
+ node .setmocktime (int (time .time ()) - 60 * 31 )
40
+ txid = node .sendtoaddress (node .getnewaddress (), 1 )
41
41
42
- # Can take a few seconds due to transaction trickling
43
- wait_until (lambda : self . nodes [ 0 ] .p2p .tx_invs_received [txid ] >= 1 )
42
+ # Can take a few seconds due to transaction trickling.
43
+ wait_until (lambda : node .p2p .tx_invs_received [txid ] >= 1 )
44
44
time_now = int (time .time ())
45
45
46
- # Add a second peer since txs aren't rebroadcast to the same peer (see filterInventoryKnown)
47
- self . nodes [ 0 ] .add_p2p_connection (P2PStoreTxInvs ())
46
+ # Add a second peer since txs aren't rebroadcast to the same peer (see filterInventoryKnown).
47
+ node .add_p2p_connection (P2PStoreTxInvs ())
48
48
49
49
# Mine a block. Transactions are only rebroadcast if a block has been mined
50
50
# since the last time we tried to broadcast. Make sure that the transaction is
51
51
# not included in the block.
52
52
# The block must be received more than 5 minutes after the transaction timestamp for the
53
53
# transaction to be rebroadcast.
54
- self .nodes [0 ].setmocktime (time_now - 60 * 25 )
55
- block = create_block (int (self .nodes [0 ].getbestblockhash (), 16 ), create_coinbase (self .nodes [0 ].getblockchaininfo ()['blocks' ]), time_now )
54
+ node .setmocktime (time_now - 60 * 25 )
55
+ block = create_block (
56
+ int (node .getbestblockhash (), 16 ),
57
+ create_coinbase (node .getblockchaininfo ()['blocks' ]),
58
+ time_now ,
59
+ )
56
60
block .nVersion = 3
57
61
block .rehash ()
58
62
block .solve ()
59
- self . nodes [ 0 ] .submitblock (ToHex (block ))
63
+ node .submitblock (ToHex (block ))
60
64
61
65
# Transaction should not be rebroadcast
62
- self . nodes [ 0 ] .p2ps [1 ].sync_with_ping ()
63
- assert_equal (self . nodes [ 0 ] .p2ps [1 ].tx_invs_received [txid ], 0 )
66
+ node .p2ps [1 ].sync_with_ping ()
67
+ assert_equal (node .p2ps [1 ].tx_invs_received [txid ], 0 )
64
68
65
- # Transaction should be broadcast after 30 minutes. Give an extra minute to be sure
66
- self . nodes [ 0 ]. setmocktime (0 )
67
- wait_until (lambda : self . nodes [ 0 ] .p2ps [1 ].tx_invs_received [txid ] >= 1 )
69
+ # Transaction should be broadcast after 30 minutes. Give it ~60 (31 + 29) to be sure.
70
+ node . setmocktime (time_now + 60 * 29 )
71
+ wait_until (lambda : node .p2ps [1 ].tx_invs_received [txid ] >= 1 )
68
72
69
73
if __name__ == '__main__' :
70
74
ResendWalletTransactionsTest ().main ()
0 commit comments