mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 18:09:47 +01:00
test: ensure banlist can be read from disk after restart
With `banlist.dat` (being written in addrv1 format) if we would try to write a Tor v3 subnet, it would serialize as a dummy-all-0s IPv6 address and subsequently, when deserialized will not result in the same subnet. This problem does not exist with `banlist.json` where the data is saved in textual, human-readable form.
This commit is contained in:
parent
d197977ae2
commit
dd4e957dcd
@ -51,12 +51,24 @@ class SetBanTests(BitcoinTestFramework):
|
||||
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))
|
||||
|
||||
self.log.info("Test the ban list is preserved through restart")
|
||||
|
||||
self.restart_node(1)
|
||||
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))
|
||||
|
||||
self.restart_node(1)
|
||||
assert(not self.is_banned(node, tor_addr))
|
||||
assert(not self.is_banned(node, ip_addr))
|
||||
|
||||
if __name__ == '__main__':
|
||||
SetBanTests().main()
|
||||
|
Loading…
Reference in New Issue
Block a user