@@ -61,10 +61,10 @@ def run_test(self):
61
61
assert_equal (0 , total_fees )
62
62
63
63
for i in ['1' , '2' , '3' ]:
64
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ i ]['size ' ])
65
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ i ]['count' ])
66
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ i ]['fees' ])
67
- assert_equal (int (i ), info ['fee_histogram' ]['fee_rate_groups' ][ i ]['from ' ])
64
+ assert_equal (0 , info ['fee_histogram' ][i ]['sizes ' ])
65
+ assert_equal (0 , info ['fee_histogram' ][i ]['count' ])
66
+ assert_equal (0 , info ['fee_histogram' ][i ]['fees' ])
67
+ assert_equal (int (i ), info ['fee_histogram' ][i ]['from_feerate ' ])
68
68
69
69
self .log .info ("Test that we have two spendable UTXOs and lock the second one" )
70
70
utxos = node .listunspent ()
@@ -80,28 +80,28 @@ def run_test(self):
80
80
(non_empty_groups , empty_groups , total_fees ) = self .histogram_stats (info ['fee_histogram' ])
81
81
assert_equal (1 , non_empty_groups )
82
82
assert_equal (3 , empty_groups )
83
- assert_equal (1 , info ['fee_histogram' ]['fee_rate_groups' ][ tx1_info ['feerate' ]]['count' ])
83
+ assert_equal (1 , info ['fee_histogram' ][tx1_info ['feerate' ]]['count' ])
84
84
assert_equal (total_fees , info ['fee_histogram' ]['total_fees' ])
85
85
86
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 1' ]['size ' ])
87
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 1' ]['count' ])
88
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 1' ]['fees' ])
89
- assert_equal (1 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 1' ]['from ' ])
86
+ assert_equal (0 , info ['fee_histogram' ]['1' ]['sizes ' ])
87
+ assert_equal (0 , info ['fee_histogram' ]['1' ]['count' ])
88
+ assert_equal (0 , info ['fee_histogram' ]['1' ]['fees' ])
89
+ assert_equal (1 , info ['fee_histogram' ]['1' ]['from_feerate ' ])
90
90
91
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 3' ]['size ' ])
92
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 3' ]['count' ])
93
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 3' ]['fees' ])
94
- assert_equal (3 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 3' ]['from ' ])
91
+ assert_equal (0 , info ['fee_histogram' ]['3' ]['sizes ' ])
92
+ assert_equal (0 , info ['fee_histogram' ]['3' ]['count' ])
93
+ assert_equal (0 , info ['fee_histogram' ]['3' ]['fees' ])
94
+ assert_equal (3 , info ['fee_histogram' ]['3' ]['from_feerate ' ])
95
95
96
- assert_equal (188 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 5' ]['size ' ])
97
- assert_equal (1 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 5' ]['count' ])
98
- assert_equal (940 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 5' ]['fees' ])
99
- assert_equal (5 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 5' ]['from ' ])
96
+ assert_equal (188 , info ['fee_histogram' ]['5' ]['sizes ' ])
97
+ assert_equal (1 , info ['fee_histogram' ]['5' ]['count' ])
98
+ assert_equal (940 , info ['fee_histogram' ]['5' ]['fees' ])
99
+ assert_equal (5 , info ['fee_histogram' ]['5' ]['from_feerate ' ])
100
100
101
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 10' ]['size ' ])
102
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 10' ]['count' ])
103
- assert_equal (0 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 10' ]['fees' ])
104
- assert_equal (10 , info ['fee_histogram' ]['fee_rate_groups' ][ ' 10' ]['from ' ])
101
+ assert_equal (0 , info ['fee_histogram' ]['10' ]['sizes ' ])
102
+ assert_equal (0 , info ['fee_histogram' ]['10' ]['count' ])
103
+ assert_equal (0 , info ['fee_histogram' ]['10' ]['fees' ])
104
+ assert_equal (10 , info ['fee_histogram' ]['10' ]['from_feerate ' ])
105
105
106
106
self .log .info ("Send tx2 transaction with 14 sat/vB fee rate (spends tx1 UTXO)" )
107
107
tx2_txid = node .sendtoaddress (address = node .getnewaddress (), amount = Decimal ("25.0" ), fee_rate = 14 , subtractfeefromamount = True )
@@ -115,7 +115,7 @@ def run_test(self):
115
115
tx1p2_feerate = get_actual_fee_rate (tx1_info ['fee' ] + tx2_info ['fee' ], tx1_info ['vsize' ] + tx2_info ['vsize' ])
116
116
assert_equal (1 , non_empty_groups )
117
117
assert_equal (14 , empty_groups )
118
- assert_equal (2 , info ['fee_histogram' ]['fee_rate_groups' ][ tx1p2_feerate ]['count' ])
118
+ assert_equal (2 , info ['fee_histogram' ][tx1p2_feerate ]['count' ])
119
119
assert_equal (total_fees , info ['fee_histogram' ]['total_fees' ])
120
120
121
121
# Unlock the second UTXO which we locked
@@ -132,26 +132,27 @@ def run_test(self):
132
132
# tx1 should be grouped with tx2 + tx3 (descendants)
133
133
# tx2 should be grouped with tx1 (ancestors only)
134
134
# tx3 should be alone
135
- expected_histogram = {
136
- 'fee_rate_groups' : dict ( (
135
+ expected_histogram = dict (
136
+ tuple (
137
137
(str (n ), {
138
- 'from ' : n ,
139
- 'to ' : n ,
138
+ 'from_feerate ' : n ,
139
+ 'to_feerate ' : n + 1 ,
140
140
'count' : 0 ,
141
141
'fees' : 0 ,
142
- 'size ' : 0 ,
142
+ 'sizes ' : 0 ,
143
143
}) for n in range (1 , 16 )
144
- ) ),
145
- 'total_fees' : tx1_info ['fee' ] + tx2_info ['fee' ] + tx3_info ['fee' ],
146
- }
147
- expected_frg = expected_histogram ['fee_rate_groups' ]
148
- expected_frg ['15' ]['to' ] = None
144
+ ) + (
145
+ ('total_fees' , tx1_info ['fee' ] + tx2_info ['fee' ] + tx3_info ['fee' ]),
146
+ )
147
+ )
148
+ expected_frg = expected_histogram
149
+ expected_frg ['15' ]['to_feerate' ] = 9223372036854775807
149
150
tx1p2p3_feerate = get_actual_fee_rate (expected_histogram ['total_fees' ], tx1_info ['vsize' ] + tx2_info ['vsize' ] + tx3_info ['vsize' ])
150
151
def inc_expected (feerate , txinfo ):
151
152
this_frg = expected_frg [feerate ]
152
153
this_frg ['count' ] += 1
153
154
this_frg ['fees' ] += txinfo ['fee' ]
154
- this_frg ['size ' ] += txinfo ['vsize' ]
155
+ this_frg ['sizes ' ] += txinfo ['vsize' ]
155
156
inc_expected (tx1p2p3_feerate , tx1_info )
156
157
inc_expected (tx1p2_feerate , tx2_info )
157
158
inc_expected (tx3_info ['feerate' ], tx3_info )
@@ -163,26 +164,23 @@ def inc_expected(feerate, txinfo):
163
164
164
165
# Verify that the 6 sat/vB fee rate group has one transaction, and the 8-9 sat/vB fee rate group has two
165
166
for collapse_n in (9 , 11 , 13 , 15 ):
166
- for field in ('count' , 'size ' , 'fees' ):
167
+ for field in ('count' , 'sizes ' , 'fees' ):
167
168
expected_frg [str (collapse_n - 1 )][field ] += expected_frg [str (collapse_n )][field ]
168
- expected_frg [str (collapse_n - 1 )]['to ' ] += 1
169
+ expected_frg [str (collapse_n - 1 )]['to_feerate ' ] += 1
169
170
del expected_frg [str (collapse_n )]
170
- expected_frg ['14' ]['to ' ] += 1 # 16 is also skipped
171
+ expected_frg ['14' ]['to_feerate ' ] += 1 # 16 is also skipped
171
172
172
173
for new_n in (17 , 20 , 25 ) + tuple (range (30 , 90 , 10 )) + (100 , 120 , 140 , 170 , 200 , 250 ) + tuple (range (300 , 900 , 100 )) + (1000 , 1200 , 1400 , 1700 , 2000 , 2500 ) + tuple (range (3000 , 9000 , 1000 )) + (10000 ,):
173
- frinfo = info ['fee_histogram' ]['fee_rate_groups' ][str (new_n )]
174
- if new_n == 10000 :
175
- assert frinfo ['to' ] is None
176
- else :
177
- assert frinfo ['to' ] > frinfo ['from' ]
178
- del frinfo ['to' ]
174
+ frinfo = info ['fee_histogram' ][str (new_n )]
175
+ assert frinfo ['to_feerate' ] > frinfo ['from_feerate' ]
176
+ del frinfo ['to_feerate' ]
179
177
assert_equal (frinfo , {
180
- 'from ' : new_n ,
178
+ 'from_feerate ' : new_n ,
181
179
'count' : 0 ,
182
180
'fees' : 0 ,
183
- 'size ' : 0 ,
181
+ 'sizes ' : 0 ,
184
182
})
185
- del info ['fee_histogram' ]['fee_rate_groups' ][ str (new_n )]
183
+ del info ['fee_histogram' ][str (new_n )]
186
184
assert_equal (expected_histogram , info ['fee_histogram' ])
187
185
188
186
self .log .info ("Test getmempoolinfo(with_fee_histogram=False) does not return fee histogram" )
@@ -193,16 +191,23 @@ def histogram_stats(self, histogram):
193
191
empty_count = 0
194
192
non_empty_count = 0
195
193
196
- for key , bin in histogram ['fee_rate_groups' ].items ():
197
- assert_equal (int (key ), bin ['from' ])
194
+ for key , bin in histogram .items ():
195
+ if key == 'total_fees' :
196
+ continue
197
+ assert_equal (int (key ), bin ['from_feerate' ])
198
198
if bin ['fees' ] > 0 :
199
199
assert_greater_than (bin ['count' ], 0 )
200
200
else :
201
201
assert_equal (bin ['count' ], 0 )
202
202
assert_greater_than_or_equal (bin ['fees' ], 0 )
203
- assert_greater_than_or_equal (bin ['size' ], 0 )
204
- if bin ['to' ] is not None :
205
- assert_greater_than_or_equal (bin ['to' ], bin ['from' ])
203
+ assert_greater_than_or_equal (bin ['sizes' ], 0 )
204
+ if bin ['to_feerate' ] is not None :
205
+ assert_greater_than_or_equal (bin ['to_feerate' ], bin ['from_feerate' ])
206
+ for next_key in sorted ((* (int (a ) for a in histogram .keys () if a != 'total_fees' ), 0x7fffffffffffffff )):
207
+ if int (next_key ) <= int (key ):
208
+ continue
209
+ assert_equal (bin ['to_feerate' ], int (next_key ))
210
+ break
206
211
total_fees += bin ['fees' ]
207
212
208
213
if bin ['count' ] == 0 :
0 commit comments