1010from test_framework .mininode import mininode_lock , P2PInterface
1111from test_framework .test_framework import BitcoinTestFramework
1212from test_framework .util import assert_equal
13+ from test_framework .wallet import MiniWallet
1314
1415
1516class FeefilterConn (P2PInterface ):
@@ -57,9 +58,6 @@ def set_test_params(self):
57585859 ]] * self .num_nodes
5960
60- def skip_test_if_missing_module (self ):
61- self .skip_if_no_wallet ()
62-
6361 def run_test (self ):
6462 self .test_feefilter_forcerelay ()
6563 self .test_feefilter ()
@@ -79,27 +77,28 @@ def test_feefilter_forcerelay(self):
7977 def test_feefilter (self ):
8078 node1 = self .nodes [1 ]
8179 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 )
8284
8385 conn = self .nodes [0 ].add_p2p_connection (TestP2PConn ())
8486
8587 self .log .info ("Test txs paying 0.2 sat/byte are received by test connection" )
86- node1 .settxfee (Decimal ("0.00000200" ))
87- 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 )]
8889 conn .wait_for_invs_to_match (txids )
8990 conn .clear_invs ()
9091
9192 # Set a fee filter of 0.15 sat/byte on test connection
9293 conn .send_and_ping (msg_feefilter (150 ))
9394
9495 self .log .info ("Test txs paying 0.15 sat/byte are received by test connection" )
95- node1 .settxfee (Decimal ("0.00000150" ))
96- 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 )]
9797 conn .wait_for_invs_to_match (txids )
9898 conn .clear_invs ()
9999
100100 self .log .info ("Test txs paying 0.1 sat/byte are no longer received by test connection" )
101- node1 .settxfee (Decimal ("0.00000100" ))
102- [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 )]
103102 self .sync_mempools () # must be sure node 0 has received all txs
104103
105104 # Send one transaction from node0 that should be received, so that we
@@ -109,14 +108,13 @@ def test_feefilter(self):
109108 # to 35 entries in an inv, which means that when this next transaction
110109 # is eligible for relay, the prior transactions from node1 are eligible
111110 # as well.
112- node0 .settxfee (Decimal ("0.00020000" ))
113- 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 )]
114112 conn .wait_for_invs_to_match (txids )
115113 conn .clear_invs ()
116114
117115 self .log .info ("Remove fee filter and check txs are received again" )
118116 conn .send_and_ping (msg_feefilter (0 ))
119- 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 )]
120118 conn .wait_for_invs_to_match (txids )
121119 conn .clear_invs ()
122120
0 commit comments