3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test that the wallet resends transactions periodically."""
6
- from collections import defaultdict
7
6
import time
8
7
9
8
from test_framework .blocktools import create_block , create_coinbase
10
9
from test_framework .messages import ToHex
11
- from test_framework .mininode import P2PInterface , mininode_lock
10
+ from test_framework .mininode import P2PTxInvStore , mininode_lock
12
11
from test_framework .test_framework import BitcoinTestFramework
13
12
from test_framework .util import assert_equal , wait_until
14
13
15
-
16
- class P2PStoreTxInvs (P2PInterface ):
17
- def __init__ (self ):
18
- super ().__init__ ()
19
- self .tx_invs_received = defaultdict (int )
20
-
21
- def on_inv (self , message ):
22
- # Store how many times invs have been received for each tx.
23
- for i in message .inv :
24
- if i .type == 1 :
25
- # save txid
26
- self .tx_invs_received [i .hash ] += 1
27
-
28
-
29
14
class ResendWalletTransactionsTest (BitcoinTestFramework ):
30
15
def set_test_params (self ):
31
16
self .num_nodes = 1
@@ -36,7 +21,7 @@ def skip_test_if_missing_module(self):
36
21
def run_test (self ):
37
22
node = self .nodes [0 ] # alias
38
23
39
- node .add_p2p_connection (P2PStoreTxInvs ())
24
+ node .add_p2p_connection (P2PTxInvStore ())
40
25
41
26
self .log .info ("Create a new transaction and wait until it's broadcast" )
42
27
txid = int (node .sendtoaddress (node .getnewaddress (), 1 ), 16 )
@@ -51,7 +36,7 @@ def run_test(self):
51
36
wait_until (lambda : node .p2p .tx_invs_received [txid ] >= 1 , lock = mininode_lock )
52
37
53
38
# Add a second peer since txs aren't rebroadcast to the same peer (see filterInventoryKnown)
54
- node .add_p2p_connection (P2PStoreTxInvs ())
39
+ node .add_p2p_connection (P2PTxInvStore ())
55
40
56
41
self .log .info ("Create a block" )
57
42
# Create and submit a block without the transaction.
0 commit comments