forked from bitcoin-core/gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Check that peers with forcerelay permission do not get a feefil…
…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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
@@ -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 @@ 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] | ||
|
||
|