Skip to content

Commit e81942d

Browse files
committed
[test] logging and style followups for bloomfilter tests
-Use peer to refer to mininodes instead of node because they are not bitcoind nodes. -Use log.debug for logs that give helpful but not super necessary information. -Adhere to style guidelines (newlines, capitalization).
1 parent 4b30c41 commit e81942d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

test/functional/p2p_filter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ def test_msg_mempool(self):
124124
self.log.info("Check that a node with bloom filters enabled services p2p mempool messages")
125125
filter_peer = P2PBloomFilter()
126126

127-
self.log.info("Create a tx relevant to the peer before connecting")
127+
self.log.debug("Create a tx relevant to the peer before connecting")
128128
filter_address = self.nodes[0].decodescript(filter_peer.watch_script_pubkey)['addresses'][0]
129129
txid = self.nodes[0].sendtoaddress(filter_address, 90)
130130

131-
self.log.info("Send a mempool msg after connecting and check that the tx is received")
131+
self.log.debug("Send a mempool msg after connecting and check that the tx is received")
132132
self.nodes[0].add_p2p_connection(filter_peer)
133133
filter_peer.send_and_ping(filter_peer.watch_filter_init)
134134
self.nodes[0].p2p.send_message(msg_mempool())
@@ -227,8 +227,8 @@ def run_test(self):
227227
self.test_frelay_false(filter_peer_without_nrelay)
228228
self.test_filter(filter_peer_without_nrelay)
229229

230-
self.log.info('Test msg_mempool')
231230
self.test_msg_mempool()
232231

232+
233233
if __name__ == '__main__':
234234
FilterTest().main()

test/functional/p2p_nobloomfilter_messages.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test invalid p2p messages for nodes with bloom filters disabled.
66
7-
Test that, when bloom filters are not enabled, nodes are disconnected if:
7+
Test that, when bloom filters are not enabled, peers are disconnected if:
88
1. They send a p2p mempool message
99
2. They send a p2p filterload message
1010
3. They send a p2p filteradd message
@@ -17,31 +17,32 @@
1717
from test_framework.util import assert_equal
1818

1919

20-
class P2PNobloomfilterMessages(BitcoinTestFramework):
20+
class P2PNoBloomFilterMessages(BitcoinTestFramework):
2121
def set_test_params(self):
2222
self.setup_clean_chain = True
2323
self.num_nodes = 1
2424
self.extra_args = [["-peerbloomfilters=0"]]
2525

2626
def test_message_causes_disconnect(self, message):
27-
# Add a p2p connection that sends a message and check that it disconnects
27+
"""Add a p2p connection that sends a message and check that it disconnects."""
2828
peer = self.nodes[0].add_p2p_connection(P2PInterface())
2929
peer.send_message(message)
3030
peer.wait_for_disconnect()
31-
assert_equal(len(self.nodes[0].getpeerinfo()), 0)
31+
assert_equal(self.nodes[0].getconnectioncount(), 0)
3232

3333
def run_test(self):
34-
self.log.info("Test that node is disconnected if it sends mempool message")
34+
self.log.info("Test that peer is disconnected if it sends mempool message")
3535
self.test_message_causes_disconnect(msg_mempool())
3636

37-
self.log.info("Test that node is disconnected if it sends filterload message")
37+
self.log.info("Test that peer is disconnected if it sends filterload message")
3838
self.test_message_causes_disconnect(msg_filterload())
3939

40-
self.log.info("Test that node is disconnected if it sends filteradd message")
40+
self.log.info("Test that peer is disconnected if it sends filteradd message")
4141
self.test_message_causes_disconnect(msg_filteradd(data=b'\xcc'))
4242

4343
self.log.info("Test that peer is disconnected if it sends a filterclear message")
4444
self.test_message_causes_disconnect(msg_filterclear())
4545

46+
4647
if __name__ == '__main__':
47-
P2PNobloomfilterMessages().main()
48+
P2PNoBloomFilterMessages().main()

0 commit comments

Comments
 (0)