diff options
author | brunoerg <brunoely.gc@gmail.com> | 2023-01-06 09:12:02 -0300 |
---|---|---|
committer | brunoerg <brunoely.gc@gmail.com> | 2023-01-06 13:33:38 -0300 |
commit | abccb27466c5a240a59f3f7c86f2bc60d51e9fee (patch) | |
tree | 1950f57dacebf1b791b844e5fd6075f7165d478c /test/functional/p2p_disconnect_ban.py | |
parent | b99f1f20f773eb55c870a033b3f2e8f13d55d0c8 (diff) | |
download | bitcoin-abccb27466c5a240a59f3f7c86f2bc60d51e9fee.tar.xz |
test: add coverage for absolute timestamp in `setban`
Diffstat (limited to 'test/functional/p2p_disconnect_ban.py')
-rwxr-xr-x | test/functional/p2p_disconnect_ban.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/functional/p2p_disconnect_ban.py b/test/functional/p2p_disconnect_ban.py index 8d4f50e681..7169cc8937 100755 --- a/test/functional/p2p_disconnect_ban.py +++ b/test/functional/p2p_disconnect_ban.py @@ -69,9 +69,13 @@ class DisconnectBanTest(BitcoinTestFramework): self.nodes[1].setban("2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19", "add", 1000) # ban for 1000 seconds listBeforeShutdown = self.nodes[1].listbanned() assert_equal("192.168.0.1/32", listBeforeShutdown[2]['address']) + + self.log.info("setban: test banning with absolute timestamp") + self.nodes[1].setban("192.168.0.2", "add", old_time + 120, True) + # Move time forward by 3 seconds so the third ban has expired self.nodes[1].setmocktime(old_time + 3) - assert_equal(len(self.nodes[1].listbanned()), 3) + assert_equal(len(self.nodes[1].listbanned()), 4) self.log.info("Test ban_duration and time_remaining") for ban in self.nodes[1].listbanned(): @@ -81,13 +85,17 @@ class DisconnectBanTest(BitcoinTestFramework): elif ban["address"] == "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19": assert_equal(ban["ban_duration"], 1000) assert_equal(ban["time_remaining"], 997) + elif ban["address"] == "192.168.0.2/32": + assert_equal(ban["ban_duration"], 120) + assert_equal(ban["time_remaining"], 117) self.restart_node(1) listAfterShutdown = self.nodes[1].listbanned() assert_equal("127.0.0.0/24", listAfterShutdown[0]['address']) assert_equal("127.0.0.0/32", listAfterShutdown[1]['address']) - assert_equal("/19" in listAfterShutdown[2]['address'], True) + assert_equal("192.168.0.2/32", listAfterShutdown[2]['address']) + assert_equal("/19" in listAfterShutdown[3]['address'], True) # Clear ban lists self.nodes[1].clearbanned() |