test: Check that peers with forcerelay permission do not get a feefilter message

This commit is contained in:
MarcoFalke 2020-06-07 10:00:41 -04:00
parent fad676b8d2
commit faabd1514f
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -10,6 +10,7 @@ import time
from test_framework.messages import MSG_TX, msg_feefilter
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
def hashToHex(hash):
@ -26,6 +27,17 @@ def allInvsMatch(invsExpected, testnode):
return False
class FeefilterConn(P2PInterface):
feefilter_received = False
def on_feefilter(self, message):
self.feefilter_received = True
def assert_feefilter_received(self, recv: bool):
with mininode_lock:
assert_equal(self.feefilter_received, recv)
class TestP2PConn(P2PInterface):
def __init__(self):
super().__init__()
@ -55,6 +67,22 @@ class FeeFilterTest(BitcoinTestFramework):
self.skip_if_no_wallet()
def run_test(self):
self.test_feefilter_forcerelay()
self.test_feefilter()
def test_feefilter_forcerelay(self):
self.log.info('Check that peers without forcerelay permission (default) get a feefilter message')
self.nodes[0].add_p2p_connection(FeefilterConn()).assert_feefilter_received(True)
self.log.info('Check that peers with forcerelay permission do not get a feefilter message')
self.restart_node(0, extra_args=['-whitelist=forcerelay@127.0.0.1'])
self.nodes[0].add_p2p_connection(FeefilterConn()).assert_feefilter_received(False)
# Restart to disconnect peers and load default extra_args
self.restart_node(0)
self.connect_nodes(1, 0)
def test_feefilter(self):
node1 = self.nodes[1]
node0 = self.nodes[0]