Merge bitcoin/bitcoin#26604: test: add coverage for -bantime

9c18992bbaf649f8c5461d5e4dc39eb1a07ffc77 test: add coverage for `-bantime` (brunoerg)

Pull request description:

  This PR adds test coverage for `-bantime`. This flag sets the time in seconds how long the IP is banned (in the case you don't explicitly set `bantime` when using `setban`).

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 9c18992bbaf649f8c5461d5e4dc39eb1a07ffc77

Tree-SHA512: e95f8608aa5df9b09cc5577daae662ed79ef5d5c69ee5e704d7c69520b9b51cc142e9e6be69d80356eda25a5215c4770b1a208638560c48cd3bc8f6d195a371f
This commit is contained in:
fanquake 2023-05-01 14:12:36 +01:00 committed by pasta
parent f725ed509a
commit deb7de26dd
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

@ -6,7 +6,8 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
p2p_port
p2p_port,
assert_equal,
)
class SetBanTests(BitcoinTestFramework):
@ -70,6 +71,11 @@ class SetBanTests(BitcoinTestFramework):
assert not self.is_banned(node, tor_addr)
assert not self.is_banned(node, ip_addr)
self.log.info("Test -bantime")
self.restart_node(1, ["-bantime=1234"])
self.nodes[1].setban("127.0.0.1", "add")
banned = self.nodes[1].listbanned()[0]
assert_equal(banned['ban_duration'], 1234)
if __name__ == '__main__':
SetBanTests().main()