diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2021-01-10 15:51:25 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-01-11 11:57:21 +0100 |
commit | bdce029191ab094a4a325b143324487f1c62ba7c (patch) | |
tree | d3ce6fd7cf2753ac4dbd2c5fa378ca403a12d2d8 /test | |
parent | c33fbab25c82b6a18773b80e8b355c987066ae5a (diff) |
test: add test for banning of non-IP addresses
Co-authored-by: Jon Atack <jon@atack.com>
Github-Pull: #20852
Rebased-From: 39b43298d9c54f9c18bef36f3d5934f57aefd088
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/rpc_setban.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/functional/rpc_setban.py b/test/functional/rpc_setban.py index bc48449084..551eb4d724 100755 --- a/test/functional/rpc_setban.py +++ b/test/functional/rpc_setban.py @@ -15,6 +15,9 @@ class SetBanTests(BitcoinTestFramework): self.setup_clean_chain = True self.extra_args = [[],[]] + def is_banned(self, node, addr): + return any(e['address'] == addr for e in node.listbanned()) + def run_test(self): # Node 0 connects to Node 1, check that the noban permission is not granted self.connect_nodes(0, 1) @@ -42,5 +45,18 @@ class SetBanTests(BitcoinTestFramework): peerinfo = self.nodes[1].getpeerinfo()[0] assert(not 'noban' in peerinfo['permissions']) + self.log.info("Test that a non-IP address can be banned/unbanned") + node = self.nodes[1] + tor_addr = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion" + ip_addr = "1.2.3.4" + assert(not self.is_banned(node, tor_addr)) + assert(not self.is_banned(node, ip_addr)) + node.setban(tor_addr, "add") + assert(self.is_banned(node, tor_addr)) + assert(not self.is_banned(node, ip_addr)) + node.setban(tor_addr, "remove") + assert(not self.is_banned(self.nodes[1], tor_addr)) + assert(not self.is_banned(node, ip_addr)) + if __name__ == '__main__': SetBanTests().main() |