mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
7874e7852e
fae91a09c453a9a95c382df765bd71e54698d5b2 test: Remove incorrect and unused try-block in assert_debug_log (MarcoFalke) Pull request description: This try block has accidentally been added by me in fa3e9f7627784ee00980590e5bf044a0e1249999. It was unused all the time, but commit 6011c9d72d1df5c2cd09de6f85c21eb4f7eb1ba8 added a `return` in the finally block, muting all exceptions. This can be tested by adding an `assert False` after any `with ...assert_debug_log...:` line. ACKs for top commit: laanwj: ACK fae91a09c453a9a95c382df765bd71e54698d5b2 ryanofsky: utACK fae91a09c453a9a95c382df765bd71e54698d5b2. I didn't know returning inside a `finally` block would cancel pending exceptions or return values, but I guess this makes sense and is a good thing to be aware of. Tree-SHA512: 47ed0165062060e9af055a3e92f1a529cd41d00476bfad64e3cd141ae084d22f926a343bb1257717e164e15459a59ab66aed198c95d18bf780d8cb0b76aa3298
48 lines
1.8 KiB
Python
Executable File
48 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2015-2019 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 the setban rpc call."""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import (
|
|
connect_nodes,
|
|
p2p_port
|
|
)
|
|
|
|
class SetBanTests(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 2
|
|
self.setup_clean_chain = True
|
|
self.extra_args = [[],[]]
|
|
|
|
def run_test(self):
|
|
# Node 0 connects to Node 1, check that the noban permission is not granted
|
|
connect_nodes(self.nodes[0], 1)
|
|
peerinfo = self.nodes[1].getpeerinfo()[0]
|
|
assert not 'noban' in peerinfo['permissions']
|
|
|
|
# Node 0 get banned by Node 1
|
|
self.nodes[1].setban("127.0.0.1", "add")
|
|
|
|
# Node 0 should not be able to reconnect
|
|
with self.nodes[1].assert_debug_log(expected_msgs=['dropped (banned)\n'], timeout=5):
|
|
self.restart_node(1, [])
|
|
self.nodes[0].addnode("127.0.0.1:" + str(p2p_port(1)), "onetry")
|
|
|
|
# However, node 0 should be able to reconnect if it has noban permission
|
|
self.restart_node(1, ['-whitelist=127.0.0.1'])
|
|
connect_nodes(self.nodes[0], 1)
|
|
peerinfo = self.nodes[1].getpeerinfo()[0]
|
|
assert 'noban' in peerinfo['permissions']
|
|
|
|
# If we remove the ban, Node 0 should be able to reconnect even without noban permission
|
|
self.nodes[1].setban("127.0.0.1", "remove")
|
|
self.restart_node(1, [])
|
|
connect_nodes(self.nodes[0], 1)
|
|
peerinfo = self.nodes[1].getpeerinfo()[0]
|
|
assert not 'noban' in peerinfo['permissions']
|
|
|
|
if __name__ == '__main__':
|
|
SetBanTests().main()
|