Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_ibd_txrelay.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020 The Bitcoin Core developers | # Copyright (c) 2020 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test fee filters during and after IBD.""" | """Test fee filters during and after IBD.""" | ||||
from decimal import Decimal | from decimal import Decimal | ||||
from test_framework.messages import XEC | from test_framework.messages import XEC | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal | |||||
MAX_FEE_FILTER = Decimal(9170997) / XEC | MAX_FEE_FILTER = Decimal(9170997) / XEC | ||||
NORMAL_FEE_FILTER = Decimal(100) / XEC | NORMAL_FEE_FILTER = Decimal(100) / XEC | ||||
class P2PIBDTxRelayTest(BitcoinTestFramework): | class P2PIBDTxRelayTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [ | self.extra_args = [ | ||||
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)], | ["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)], | ||||
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)], | ["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)], | ||||
] | ] | ||||
def run_test(self): | def run_test(self): | ||||
self.log.info( | self.log.info( | ||||
"Check that nodes set minfilter to MAX_MONEY while still in IBD") | "Check that nodes set minfilter to MAX_MONEY while still in IBD") | ||||
for node in self.nodes: | for node in self.nodes: | ||||
assert node.getblockchaininfo()['initialblockdownload'] | assert node.getblockchaininfo()['initialblockdownload'] | ||||
for conn_info in node.getpeerinfo(): | self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER | ||||
assert_equal(conn_info['minfeefilter'], MAX_FEE_FILTER) | for peer in node.getpeerinfo())) | ||||
# Come out of IBD by generating a block | # Come out of IBD by generating a block | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
self.log.info( | self.log.info( | ||||
"Check that nodes reset minfilter after coming out of IBD") | "Check that nodes reset minfilter after coming out of IBD") | ||||
for node in self.nodes: | for node in self.nodes: | ||||
assert not node.getblockchaininfo()['initialblockdownload'] | assert not node.getblockchaininfo()['initialblockdownload'] | ||||
for conn_info in node.getpeerinfo(): | self.wait_until( | ||||
assert_equal(conn_info['minfeefilter'], NORMAL_FEE_FILTER) | lambda: all(peer['minfeefilter'] == NORMAL_FEE_FILTER | ||||
for peer in node.getpeerinfo())) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
P2PIBDTxRelayTest().main() | P2PIBDTxRelayTest().main() |