Skip to content

Commit

Permalink
test: Check that peers with forcerelay permission do not get a feefil…
Browse files Browse the repository at this point in the history
…ter message
  • Loading branch information
MarcoFalke committed Jun 21, 2020
1 parent fad676b commit faabd15
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/functional/p2p_feefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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):
Expand All @@ -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__()
Expand Down Expand Up @@ -55,6 +67,22 @@ def skip_test_if_missing_module(self):
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=['[email protected]'])
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]

Expand Down

0 comments on commit faabd15

Please sign in to comment.