10
10
from test_framework .mininode import mininode_lock , P2PInterface
11
11
from test_framework .test_framework import BitcoinTestFramework
12
12
from test_framework .util import assert_equal
13
+ from test_framework .wallet import MiniWallet
13
14
14
15
15
16
class FeefilterConn (P2PInterface ):
@@ -57,9 +58,6 @@ def set_test_params(self):
57
58
58
59
]] * self .num_nodes
59
60
60
- def skip_test_if_missing_module (self ):
61
- self .skip_if_no_wallet ()
62
-
63
61
def run_test (self ):
64
62
self .test_feefilter_forcerelay ()
65
63
self .test_feefilter ()
@@ -79,27 +77,28 @@ def test_feefilter_forcerelay(self):
79
77
def test_feefilter (self ):
80
78
node1 = self .nodes [1 ]
81
79
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 )
82
84
83
85
conn = self .nodes [0 ].add_p2p_connection (TestP2PConn ())
84
86
85
87
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 )]
88
89
conn .wait_for_invs_to_match (txids )
89
90
conn .clear_invs ()
90
91
91
92
# Set a fee filter of 0.15 sat/byte on test connection
92
93
conn .send_and_ping (msg_feefilter (150 ))
93
94
94
95
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 )]
97
97
conn .wait_for_invs_to_match (txids )
98
98
conn .clear_invs ()
99
99
100
100
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 )]
103
102
self .sync_mempools () # must be sure node 0 has received all txs
104
103
105
104
# Send one transaction from node0 that should be received, so that we
@@ -109,14 +108,13 @@ def test_feefilter(self):
109
108
# to 35 entries in an inv, which means that when this next transaction
110
109
# is eligible for relay, the prior transactions from node1 are eligible
111
110
# 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 )]
114
112
conn .wait_for_invs_to_match (txids )
115
113
conn .clear_invs ()
116
114
117
115
self .log .info ("Remove fee filter and check txs are received again" )
118
116
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 )]
120
118
conn .wait_for_invs_to_match (txids )
121
119
conn .clear_invs ()
122
120
0 commit comments