mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
test: add test for banning of non-IP addresses
Co-authored-by: Jon Atack <jon@atack.com>
This commit is contained in:
parent
94d335da7f
commit
39b43298d9
1 changed files with 16 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue