mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
e12afdf175
37389c7d38
Merge bitcoin/bitcoin#28781: depends: latest config.guess & config.sub (fanquake)3239f1525d
Merge bitcoin/bitcoin#28479: build: use _LIBCPP_ENABLE_DEBUG_MODE over ENABLE_ASSERTIONS (fanquake)45cc44bcf9
Merge bitcoin/bitcoin#27628: build: Fix shared lib linking for darwin with lld (fanquake)b8ddcd937c
Merge bitcoin/bitcoin#27575: Introduce platform-agnostic `ALWAYS_INLINE` macro (fanquake)71c6d7f6ca
Merge bitcoin/bitcoin#26653: test, init: perturb file to ensure failure instead of only deleting them (fanquake)417f71a587
Merge bitcoin/bitcoin#27422: test: add coverage to rpc_scantxoutset.py (fanquake)898dcbdc4f
Merge bitcoin/bitcoin#27559: doc: clarify processing of mempool-msgs when NODE_BLOOM (glozow)a4e429cb5a
Merge bitcoin/bitcoin#26953: contrib: add ELF OS ABI check to symbol-check.py (fanquake)deb7de26dd
Merge bitcoin/bitcoin#26604: test: add coverage for `-bantime` (fanquake)f725ed509a
Merge bitcoin/bitcoin#26314: test: perturb anchors.dat to test error during initialization (fanquake)3306f96d80
Merge bitcoin/bitcoin#25937: test: add coverage for rpc error when trying to rescan beyond pruned data (fanquake)712dcaf86b
Merge bitcoin/bitcoin#27516: test: simplify uint256 (de)serialization routines (fanquake)90d65f25e1
Merge bitcoin/bitcoin#27508: build: use latest config.{guess,sub} in depends (fanquake)df7be026e4
Merge bitcoin/bitcoin#27506: test: prevent intermittent failures (fanquake)9b58b2d97b
Merge bitcoin/bitcoin#27447: depends: Remove `_LIBCPP_DEBUG` from depends DEBUG mode (fanquake)07770b77a1
Merge bitcoin/bitcoin#26741: doc: FreeBSD DataDirectoryGroupReadable Setting (fanquake)5645362f11
Merge bitcoin/bitcoin#27362: test: remove `GetRNGState` lsan suppression (fanquake)671e8e6851
Merge bitcoin/bitcoin#27368: refactor: Drop no longer used `CNetMsgMaker` instances (fanquake)a11690bf62
Merge bitcoin/bitcoin#27301: depends: make fontconfig build under clang-16 (fanquake)0a94b3f27b
Merge bitcoin/bitcoin#27328: depends: fix osx build with clang 16 (fanquake) Pull request description: ## Issue being fixed or feature implemented Batch of trivial backports ## What was done? See commits ## How Has This Been Tested? built locally; large combined merge passed tests locally ## Breaking Changes Should be none ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK37389c7d38
kwvg: utACK37389c7d38
Tree-SHA512: 1ea075a58361f57e037febcf003d380ab845b6c8e1c62d9fcf8954d46cd006046d1951f15a41a5deb9ab7af734df9dafcf89f33d115d78246752f7e2cd13f4ee
89 lines
3.4 KiB
Python
Executable File
89 lines
3.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2015-2020 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test the setban rpc call."""
|
|
|
|
from contextlib import ExitStack
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import (
|
|
p2p_port,
|
|
assert_equal,
|
|
)
|
|
|
|
class SetBanTests(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 2
|
|
self.setup_clean_chain = True
|
|
self.extra_args = [[],[]]
|
|
|
|
def is_banned(self, node, addr):
|
|
return any(e['address'] == addr for e in node.listbanned())
|
|
|
|
def run_test(self):
|
|
# 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"]
|
|
|
|
# Node 0 get banned by Node 1
|
|
self.nodes[1].setban("127.0.0.1", "add")
|
|
|
|
# Node 0 should not be able to reconnect
|
|
context = ExitStack()
|
|
context.enter_context(self.nodes[1].assert_debug_log(expected_msgs=['dropped (banned)\n'], timeout=50))
|
|
# When disconnected right after connecting, a v2 node will attempt to reconnect with v1.
|
|
# Wait for that to happen so that it cannot mess with later tests.
|
|
if self.options.v2transport:
|
|
context.enter_context(self.nodes[0].assert_debug_log(expected_msgs=['trying v1 connection'], timeout=50))
|
|
with context:
|
|
self.restart_node(1, [])
|
|
self.nodes[0].addnode("127.0.0.1:" + str(p2p_port(1)), "onetry")
|
|
|
|
# However, node 0 should be able to reconnect if it has noban permission
|
|
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"]
|
|
|
|
# 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"]
|
|
|
|
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)
|
|
|
|
node.setban(tor_addr, "add")
|
|
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)
|
|
|
|
self.restart_node(1)
|
|
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()
|