1010from test_framework .p2p import P2PInterface , p2p_lock
1111from test_framework .test_framework import BitcoinTestFramework
1212from test_framework .util import assert_equal
13-
14-
15- def hashToHex (hash ):
16- return format (hash , '064x' )
13+ from test_framework .wallet import MiniWallet
1714
1815
1916class FeefilterConn (P2PInterface ):
@@ -35,7 +32,7 @@ def __init__(self):
3532 def on_inv (self , message ):
3633 for i in message .inv :
3734 if (i .type == MSG_TX ) or (i .type == MSG_WTX ):
38- self .txinvs .append (hashToHex (i .hash ))
35+ self .txinvs .append ('{:064x}' . format (i .hash ))
3936
4037 def wait_for_invs_to_match (self , invs_expected ):
4138 invs_expected .sort ()
@@ -61,9 +58,6 @@ def set_test_params(self):
61586259 ]] * self .num_nodes
6360
64- def skip_test_if_missing_module (self ):
65- self .skip_if_no_wallet ()
66-
6761 def run_test (self ):
6862 self .test_feefilter_forcerelay ()
6963 self .test_feefilter ()
@@ -83,27 +77,28 @@ def test_feefilter_forcerelay(self):
8377 def test_feefilter (self ):
8478 node1 = self .nodes [1 ]
8579 node0 = self .nodes [0 ]
80+ miniwallet = MiniWallet (node1 )
81+ # Add enough mature utxos to the wallet, so that all txs spend confirmed coins
82+ miniwallet .generate (5 )
83+ node1 .generate (100 )
8684
8785 conn = self .nodes [0 ].add_p2p_connection (TestP2PConn ())
8886
8987 self .log .info ("Test txs paying 0.2 sat/byte are received by test connection" )
90- node1 .settxfee (Decimal ("0.00000200" ))
91- txids = [node1 .sendtoaddress (node1 .getnewaddress (), 1 ) for _ in range (3 )]
88+ txids = [miniwallet .send_self_transfer (fee_rate = Decimal ('0.00000200' ), from_node = node1 )['wtxid' ] for _ in range (3 )]
9289 conn .wait_for_invs_to_match (txids )
9390 conn .clear_invs ()
9491
9592 # Set a fee filter of 0.15 sat/byte on test connection
9693 conn .send_and_ping (msg_feefilter (150 ))
9794
9895 self .log .info ("Test txs paying 0.15 sat/byte are received by test connection" )
99- node1 .settxfee (Decimal ("0.00000150" ))
100- txids = [node1 .sendtoaddress (node1 .getnewaddress (), 1 ) for _ in range (3 )]
96+ txids = [miniwallet .send_self_transfer (fee_rate = Decimal ('0.00000150' ), from_node = node1 )['wtxid' ] for _ in range (3 )]
10197 conn .wait_for_invs_to_match (txids )
10298 conn .clear_invs ()
10399
104100 self .log .info ("Test txs paying 0.1 sat/byte are no longer received by test connection" )
105- node1 .settxfee (Decimal ("0.00000100" ))
106- [node1 .sendtoaddress (node1 .getnewaddress (), 1 ) for _ in range (3 )]
101+ txids = [miniwallet .send_self_transfer (fee_rate = Decimal ('0.00000100' ), from_node = node1 )['wtxid' ] for _ in range (3 )]
107102 self .sync_mempools () # must be sure node 0 has received all txs
108103
109104 # Send one transaction from node0 that should be received, so that we
@@ -113,14 +108,13 @@ def test_feefilter(self):
113108 # to 35 entries in an inv, which means that when this next transaction
114109 # is eligible for relay, the prior transactions from node1 are eligible
115110 # as well.
116- node0 .settxfee (Decimal ("0.00020000" ))
117- txids = [node0 .sendtoaddress (node0 .getnewaddress (), 1 )]
111+ txids = [miniwallet .send_self_transfer (fee_rate = Decimal ('0.00020000' ), from_node = node0 )['wtxid' ] for _ in range (3 )]
118112 conn .wait_for_invs_to_match (txids )
119113 conn .clear_invs ()
120114
121115 self .log .info ("Remove fee filter and check txs are received again" )
122116 conn .send_and_ping (msg_feefilter (0 ))
123- txids = [node1 . sendtoaddress ( node1 . getnewaddress ( ), 1 ) for _ in range (3 )]
117+ txids = [miniwallet . send_self_transfer ( fee_rate = Decimal ( '0.00020000' ), from_node = node1 )[ 'wtxid' ] for _ in range (3 )]
124118 conn .wait_for_invs_to_match (txids )
125119 conn .clear_invs ()
126120
0 commit comments