|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2020 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 fee filters during and after IBD.""" |
| 6 | + |
| 7 | +from decimal import Decimal |
| 8 | + |
| 9 | +from test_framework.messages import COIN |
| 10 | +from test_framework.test_framework import BitcoinTestFramework |
| 11 | +from test_framework.util import assert_equal |
| 12 | + |
| 13 | +MAX_FEE_FILTER = Decimal(9170997) / COIN |
| 14 | +NORMAL_FEE_FILTER = Decimal(100) / COIN |
| 15 | + |
| 16 | + |
| 17 | +class P2PIBDTxRelayTest(BitcoinTestFramework): |
| 18 | + def set_test_params(self): |
| 19 | + self.setup_clean_chain = True |
| 20 | + self.num_nodes = 2 |
| 21 | + self.extra_args = [ |
| 22 | + ["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)], |
| 23 | + ["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)], |
| 24 | + ] |
| 25 | + def run_test(self): |
| 26 | + self.log.info("Check that nodes set minfilter to MAX_MONEY while still in IBD") |
| 27 | + for node in self.nodes: |
| 28 | + assert node.getblockchaininfo()['initialblockdownload'] |
| 29 | + for conn_info in node.getpeerinfo(): |
| 30 | + assert_equal(conn_info['minfeefilter'], MAX_FEE_FILTER) |
| 31 | + |
| 32 | + # Come out of IBD by generating a block |
| 33 | + self.nodes[0].generate(1) |
| 34 | + self.sync_all() |
| 35 | + |
| 36 | + self.log.info("Check that nodes reset minfilter after coming out of IBD") |
| 37 | + for node in self.nodes: |
| 38 | + assert not node.getblockchaininfo()['initialblockdownload'] |
| 39 | + for conn_info in node.getpeerinfo(): |
| 40 | + assert_equal(conn_info['minfeefilter'], NORMAL_FEE_FILTER) |
| 41 | + |
| 42 | + |
| 43 | +if __name__ == '__main__': |
| 44 | + P2PIBDTxRelayTest().main() |
0 commit comments