aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-06-23 10:01:50 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-06-23 10:01:56 +0200
commitd6e0d78c31557660274ef53cac912c468eecbe2d (patch)
treedbe980b0f2a3fe3ac51e3120ece3ef98dae1e5ae /test
parent03aa59a4e58f6cf98bc803699ea4e117bdc2a9f1 (diff)
parentbb719a08db173a753984a04534de6f148b87b17a (diff)
downloadbitcoin-d6e0d78c31557660274ef53cac912c468eecbe2d.tar.xz
Merge bitcoin/bitcoin#20966: banman: save the banlist in a JSON format on disk
bb719a08db173a753984a04534de6f148b87b17a style: remove () from assert in rpc_setban.py (Vasil Dimov) 24b10ebda301548b8ff4b0c73fefc367ad5dc22b doc: fix grammar in doc/files.md (Vasil Dimov) dd4e957dcdfc971a4a971995ff2db9fb787d23c3 test: ensure banlist can be read from disk after restart (Vasil Dimov) d197977ae2076903ed12ab7616a7f93e88be02e1 banman: save the banlist in a JSON format on disk (Vasil Dimov) Pull request description: Save the banlist in `banlist.json` instead of `banlist.dat`. This makes it possible to store Tor v3 entries in the banlist on disk (and any other addresses that cannot be serialized in addrv1 format). Only read `banlist.dat` if it exists and `banlist.json` does not exist (first start after an upgrade). Supersedes https://github.com/bitcoin/bitcoin/pull/20904 Resolves https://github.com/bitcoin/bitcoin/issues/19748 ACKs for top commit: jonatack: Code review re-ACK bb719a08db173a753984a04534de6f148b87b17a per `git range-diff 6a67366 4b52c72 bb719a0` achow101: Code Review ACK bb719a08db173a753984a04534de6f148b87b17a Tree-SHA512: fc135c3a1fe20bcf5d008ce6bea251b4135e56c78bf8f750b4bd8144c095b81ffe165133cdc7e4715875eec7e7c4e13ad9f5d2450b21102af063d7c8abf716b6
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_setban.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/test/functional/rpc_setban.py b/test/functional/rpc_setban.py
index fd5f8aa098..36873f964b 100755
--- a/test/functional/rpc_setban.py
+++ b/test/functional/rpc_setban.py
@@ -22,7 +22,7 @@ class SetBanTests(BitcoinTestFramework):
# Node 0 connects to Node 1, check that the noban permission is not granted
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
- assert(not 'noban' in peerinfo['permissions'])
+ assert not "noban" in peerinfo["permissions"]
# Node 0 get banned by Node 1
self.nodes[1].setban("127.0.0.1", "add")
@@ -36,27 +36,40 @@ class SetBanTests(BitcoinTestFramework):
self.restart_node(1, ['-whitelist=127.0.0.1'])
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
- assert('noban' in peerinfo['permissions'])
+ 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, [])
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
- assert(not 'noban' in peerinfo['permissions'])
+ 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))
+ 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))
+ 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))
+ 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()