Skip to content

Commit 03cb2fc

Browse files
committed
Merge bitcoin/bitcoin#26794: test: test banlist database recreation
4bdcf57 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 4bdcf57 Tree-SHA512: d9d0cd0c4b3797189dff00d3a634878188e7cf51e78346601fc97e2bf78c495561705214062bb42ab8e491e0d111f8bfcf74dbc801768bc02cf2b45f162aad85
2 parents ba4076d + 4bdcf57 commit 03cb2fc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/functional/p2p_disconnect_ban.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test node disconnect and ban behavior"""
66
import time
7+
from pathlib import Path
78

89
from test_framework.test_framework import BitcoinTestFramework
910
from test_framework.util import (
@@ -36,6 +37,17 @@ def run_test(self):
3637
self.log.info("clearbanned: successfully clear ban list")
3738
self.nodes[1].clearbanned()
3839
assert_equal(len(self.nodes[1].listbanned()), 0)
40+
41+
self.log.info('Test banlist database recreation')
42+
self.stop_node(1)
43+
target_file = self.nodes[1].chain_path / "banlist.json"
44+
Path.unlink(target_file)
45+
with self.nodes[1].assert_debug_log(["Recreating the banlist database"]):
46+
self.start_node(1)
47+
48+
assert Path.exists(target_file)
49+
assert_equal(self.nodes[1].listbanned(), [])
50+
3951
self.nodes[1].setban("127.0.0.0/24", "add")
4052

4153
self.log.info("setban: fail to ban an already banned subnet")

0 commit comments

Comments
 (0)