|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2018 The Bitcoin Core developers |
| 3 | +# Distributed under the MIT software license, see the accompanying |
| 4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | +"""Test the estimatefee RPCs. |
| 6 | +
|
| 7 | +Test the following RPCs: |
| 8 | + - estimatesmartfee |
| 9 | + - estimaterawfee |
| 10 | +""" |
| 11 | + |
| 12 | +from test_framework.test_framework import BitcoinTestFramework |
| 13 | +from test_framework.util import assert_raises_rpc_error |
| 14 | + |
| 15 | +class EstimateFeeTest(BitcoinTestFramework): |
| 16 | + def set_test_params(self): |
| 17 | + self.setup_clean_chain = False |
| 18 | + self.num_nodes = 1 |
| 19 | + |
| 20 | + def run_test(self): |
| 21 | + # missing required params |
| 22 | + assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee) |
| 23 | + assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee) |
| 24 | + |
| 25 | + # wrong type for conf_target |
| 26 | + assert_raises_rpc_error(-3, "Expected type number, got string", self.nodes[0].estimatesmartfee, 'foo') |
| 27 | + assert_raises_rpc_error(-3, "Expected type number, got string", self.nodes[0].estimaterawfee, 'foo') |
| 28 | + |
| 29 | + # wrong type for estimatesmartfee(estimate_mode) |
| 30 | + assert_raises_rpc_error(-3, "Expected type string, got number", self.nodes[0].estimatesmartfee, 1, 1) |
| 31 | + assert_raises_rpc_error(-8, "Invalid estimate_mode parameter", self.nodes[0].estimatesmartfee, 1, 'foo') |
| 32 | + |
| 33 | + # wrong type for estimaterawfee(threshold) |
| 34 | + assert_raises_rpc_error(-3, "Expected type number, got string", self.nodes[0].estimaterawfee, 1, 'foo') |
| 35 | + |
| 36 | + # extra params |
| 37 | + assert_raises_rpc_error(-1, "estimatesmartfee", self.nodes[0].estimatesmartfee, 1, 'ECONOMICAL', 1) |
| 38 | + assert_raises_rpc_error(-1, "estimaterawfee", self.nodes[0].estimaterawfee, 1, 1, 1) |
| 39 | + |
| 40 | + # valid calls |
| 41 | + self.nodes[0].estimatesmartfee(1) |
| 42 | + # self.nodes[0].estimatesmartfee(1, None) |
| 43 | + self.nodes[0].estimatesmartfee(1, 'ECONOMICAL') |
| 44 | + |
| 45 | + self.nodes[0].estimaterawfee(1) |
| 46 | + self.nodes[0].estimaterawfee(1, None) |
| 47 | + self.nodes[0].estimaterawfee(1, 1) |
| 48 | + |
| 49 | + |
| 50 | +if __name__ == '__main__': |
| 51 | + EstimateFeeTest().main() |
0 commit comments