Skip to content

Commit a5623b1

Browse files
author
John Newbery
committed
[tests] Remove tests for deprecated estimatefee RPC
1 parent d119f2e commit a5623b1

File tree

1 file changed

+26
-48
lines changed

1 file changed

+26
-48
lines changed

test/functional/feature_fee_estimation.py

+26-48
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
from test_framework.mininode import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
1010
from test_framework.script import CScript, OP_1, OP_DROP, OP_2, OP_HASH160, OP_EQUAL, hash160, OP_TRUE
1111
from test_framework.test_framework import BitcoinTestFramework
12-
from test_framework.util import satoshi_round, sync_mempools, sync_blocks, connect_nodes, assert_greater_than
12+
from test_framework.util import (
13+
assert_equal,
14+
assert_greater_than,
15+
assert_greater_than_or_equal,
16+
connect_nodes,
17+
satoshi_round,
18+
sync_blocks,
19+
sync_mempools,
20+
)
1321

1422
# Construct 2 trivial P2SH's and the ScriptSigs that spend them
1523
# So we can create many transactions without needing to spend
@@ -22,8 +30,6 @@
2230
# Associated ScriptSig's to spend satisfy P2SH_1 and P2SH_2
2331
SCRIPT_SIG = [CScript([OP_TRUE, REDEEM_SCRIPT_1]), CScript([OP_TRUE, REDEEM_SCRIPT_2])]
2432

25-
global log
26-
2733
def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee_increment):
2834
"""Create and send a transaction with a random fee.
2935
@@ -93,52 +99,28 @@ def split_inputs(from_node, txins, txouts, initial_split=False):
9399
txouts.append({"txid": txid, "vout": 0, "amount": half_change})
94100
txouts.append({"txid": txid, "vout": 1, "amount": rem_change})
95101

96-
def check_estimates(node, fees_seen, max_invalid, print_estimates=True):
97-
"""Call estimatefee and verify that the estimates meet certain invariants."""
102+
def check_estimates(node, fees_seen, max_invalid):
103+
"""Call estimatesmartfee and verify that the estimates meet certain invariants."""
98104

99-
all_estimates = [node.estimatefee(i) for i in range(1, 26)]
100-
if print_estimates:
101-
log.info([str(all_estimates[e - 1]) for e in [1, 2, 3, 6, 15, 25]])
102105
delta = 1.0e-6 # account for rounding error
103-
last_e = max(fees_seen)
104-
for e in [x for x in all_estimates if x >= 0]:
105-
# Estimates should be within the bounds of what transactions fees actually were:
106-
if float(e) + delta < min(fees_seen) or float(e) - delta > max(fees_seen):
106+
last_feerate = float(max(fees_seen))
107+
all_smart_estimates = [node.estimatesmartfee(i) for i in range(1, 26)]
108+
for i, e in enumerate(all_smart_estimates): # estimate is for i+1
109+
feerate = float(e["feerate"])
110+
assert_greater_than(feerate, 0)
111+
112+
if feerate + delta < min(fees_seen) or feerate - delta > max(fees_seen):
107113
raise AssertionError("Estimated fee (%f) out of range (%f,%f)"
108-
% (float(e), min(fees_seen), max(fees_seen)))
109-
# Estimates should be monotonically decreasing
110-
if float(e) - delta > last_e:
114+
% (feerate, min(fees_seen), max(fees_seen)))
115+
if feerate - delta > last_feerate:
111116
raise AssertionError("Estimated fee (%f) larger than last fee (%f) for lower number of confirms"
112-
% (float(e), float(last_e)))
113-
last_e = e
114-
valid_estimate = False
115-
invalid_estimates = 0
116-
for i, e in enumerate(all_estimates): # estimate is for i+1
117-
if e >= 0:
118-
valid_estimate = True
119-
if i >= 13: # for n>=14 estimatesmartfee(n/2) should be at least as high as estimatefee(n)
120-
assert_greater_than(node.estimatesmartfee((i + 1) // 2)["feerate"], float(e) - delta)
117+
% (feerate, last_feerate))
118+
last_feerate = feerate
121119

120+
if i == 0:
121+
assert_equal(e["blocks"], 2)
122122
else:
123-
invalid_estimates += 1
124-
125-
# estimatesmartfee should still be valid
126-
approx_estimate = node.estimatesmartfee(i + 1)["feerate"]
127-
answer_found = node.estimatesmartfee(i + 1)["blocks"]
128-
assert_greater_than(approx_estimate, 0)
129-
assert_greater_than(answer_found, i + 1)
130-
131-
# Once we're at a high enough confirmation count that we can give an estimate
132-
# We should have estimates for all higher confirmation counts
133-
if valid_estimate:
134-
raise AssertionError("Invalid estimate appears at higher confirm count than valid estimate")
135-
136-
# Check on the expected number of different confirmation counts
137-
# that we might not have valid estimates for
138-
if invalid_estimates > max_invalid:
139-
raise AssertionError("More than (%d) invalid estimates" % (max_invalid))
140-
return all_estimates
141-
123+
assert_greater_than_or_equal(i + 1, e["blocks"])
142124

143125
class EstimateFeeTest(BitcoinTestFramework):
144126
def set_test_params(self):
@@ -151,7 +133,7 @@ def setup_network(self):
151133
which we will use to generate our transactions.
152134
"""
153135
self.add_nodes(3, extra_args=[["-maxorphantx=1000", "-whitelist=127.0.0.1"],
154-
["-blockmaxsize=17000", "-maxorphantx=1000", "-deprecatedrpc=estimatefee"],
136+
["-blockmaxsize=17000", "-maxorphantx=1000"],
155137
["-blockmaxsize=8000", "-maxorphantx=1000"]])
156138
# Use node0 to mine blocks for input splitting
157139
# Node1 mines small blocks but that are bigger than the expected transaction rate.
@@ -190,10 +172,6 @@ def run_test(self):
190172
self.log.info("This test is time consuming, please be patient")
191173
self.log.info("Splitting inputs so we can generate tx's")
192174

193-
# Make log handler available to helper functions
194-
global log
195-
log = self.log
196-
197175
# Start node0
198176
self.start_node(0)
199177
self.txouts = []

0 commit comments

Comments
 (0)