aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-04-27 10:06:34 +0100
committerfanquake <fanquake@gmail.com>2023-04-27 10:18:57 +0100
commit03cb2fce4a2dc5454e61f648046b9bcd24d66186 (patch)
tree0530fdc4c34783f9eb5d2345ac9ee6b3d562a586 /test/functional
parentba4076d26f8668633ea03072347a5288e21d55f5 (diff)
parent4bdcf571584cbe44ad5533a3c991d3b0b4b2c84f (diff)
downloadbitcoin-03cb2fce4a2dc5454e61f648046b9bcd24d66186.tar.xz
Merge bitcoin/bitcoin#26794: test: test banlist database recreation
4bdcf571584cbe44ad5533a3c991d3b0b4b2c84f test: test banlist database recreation (brunoerg) Pull request description: This PR adds test coverage for 'banlist database recreation'. If it wasn't able to read ban db (in `LoadBanlist`), so it should create a new (an empty, ofc) one. https://github.com/bitcoin/bitcoin/blob/d8bdee0fc889def7c5f5076da13db4fce0a3728a/src/banman.cpp#L28-L45 ACKs for top commit: MarcoFalke: lgtm ACK 4bdcf571584cbe44ad5533a3c991d3b0b4b2c84f Tree-SHA512: d9d0cd0c4b3797189dff00d3a634878188e7cf51e78346601fc97e2bf78c495561705214062bb42ab8e491e0d111f8bfcf74dbc801768bc02cf2b45f162aad85
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/p2p_disconnect_ban.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/p2p_disconnect_ban.py b/test/functional/p2p_disconnect_ban.py
index 394009f30f..c389ff732f 100755
--- a/test/functional/p2p_disconnect_ban.py
+++ b/test/functional/p2p_disconnect_ban.py
@@ -4,6 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test node disconnect and ban behavior"""
import time
+from pathlib import Path
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -36,6 +37,17 @@ class DisconnectBanTest(BitcoinTestFramework):
self.log.info("clearbanned: successfully clear ban list")
self.nodes[1].clearbanned()
assert_equal(len(self.nodes[1].listbanned()), 0)
+
+ self.log.info('Test banlist database recreation')
+ self.stop_node(1)
+ target_file = self.nodes[1].chain_path / "banlist.json"
+ Path.unlink(target_file)
+ with self.nodes[1].assert_debug_log(["Recreating the banlist database"]):
+ self.start_node(1)
+
+ assert Path.exists(target_file)
+ assert_equal(self.nodes[1].listbanned(), [])
+
self.nodes[1].setban("127.0.0.0/24", "add")
self.log.info("setban: fail to ban an already banned subnet")