forked from DigiByte-Core/digibyte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2p_ibd_txrelay.py
executable file
·54 lines (42 loc) · 2.16 KB
/
p2p_ibd_txrelay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test fee filters during and after IBD."""
from decimal import Decimal
from test_framework.messages import COIN
from test_framework.test_framework import DigiByteTestFramework
MAX_FEE_FILTER = Decimal(9936506125) / COIN
NORMAL_FEE_FILTER = Decimal(1000) / COIN
class P2PIBDTxRelayTest(DigiByteTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2
self.extra_args = [
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
]
def run_test(self):
self.log.info("Check that nodes set minfilter to MAX_MONEY while still in IBD")
for node in self.nodes:
blockchain_info = node.getblockchaininfo()
assert blockchain_info['initialblockdownload']
self.log.info(f"Node {node.index} blockchain info: {blockchain_info}")
peer_info = node.getpeerinfo()
for peer in peer_info:
self.log.info(f"Node {node.index} peer {peer['id']} minfeefilter: {peer['minfeefilter']}")
self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
# Come out of IBD by generating a block
self.generate(self.nodes[0], 1)
self.sync_all()
self.log.info("Check that nodes reset minfilter after coming out of IBD")
for node in self.nodes:
blockchain_info = node.getblockchaininfo()
assert not blockchain_info['initialblockdownload']
self.log.info(f"Node {node.index} blockchain info: {blockchain_info}")
peer_info = node.getpeerinfo()
for peer in peer_info:
self.log.info(f"Node {node.index} peer {peer['id']} minfeefilter: {peer['minfeefilter']}")
self.wait_until(lambda: all(peer['minfeefilter'] == NORMAL_FEE_FILTER for peer in node.getpeerinfo()))
if __name__ == '__main__':
P2PIBDTxRelayTest().main()