10
10
from test_framework .p2p import P2PInterface , p2p_lock
11
11
from test_framework .test_framework import BitcoinTestFramework
12
12
from test_framework .util import assert_equal
13
-
14
-
15
- def hashToHex (hash ):
16
- return format (hash , '064x' )
13
+ from test_framework .wallet import MiniWallet
17
14
18
15
19
16
class FeefilterConn (P2PInterface ):
@@ -35,7 +32,7 @@ def __init__(self):
35
32
def on_inv (self , message ):
36
33
for i in message .inv :
37
34
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 ))
39
36
40
37
def wait_for_invs_to_match (self , invs_expected ):
41
38
invs_expected .sort ()
@@ -61,9 +58,6 @@ def set_test_params(self):
61
58
62
59
]] * self .num_nodes
63
60
64
- def skip_test_if_missing_module (self ):
65
- self .skip_if_no_wallet ()
66
-
67
61
def run_test (self ):
68
62
self .test_feefilter_forcerelay ()
69
63
self .test_feefilter ()
@@ -83,27 +77,28 @@ def test_feefilter_forcerelay(self):
83
77
def test_feefilter (self ):
84
78
node1 = self .nodes [1 ]
85
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 )
86
84
87
85
conn = self .nodes [0 ].add_p2p_connection (TestP2PConn ())
88
86
89
87
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 )]
92
89
conn .wait_for_invs_to_match (txids )
93
90
conn .clear_invs ()
94
91
95
92
# Set a fee filter of 0.15 sat/byte on test connection
96
93
conn .send_and_ping (msg_feefilter (150 ))
97
94
98
95
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 )]
101
97
conn .wait_for_invs_to_match (txids )
102
98
conn .clear_invs ()
103
99
104
100
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 )]
107
102
self .sync_mempools () # must be sure node 0 has received all txs
108
103
109
104
# Send one transaction from node0 that should be received, so that we
@@ -113,14 +108,13 @@ def test_feefilter(self):
113
108
# to 35 entries in an inv, which means that when this next transaction
114
109
# is eligible for relay, the prior transactions from node1 are eligible
115
110
# 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 )]
118
112
conn .wait_for_invs_to_match (txids )
119
113
conn .clear_invs ()
120
114
121
115
self .log .info ("Remove fee filter and check txs are received again" )
122
116
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 )]
124
118
conn .wait_for_invs_to_match (txids )
125
119
conn .clear_invs ()
126
120
0 commit comments