merge bitcoin#23392: move check_node_connections to util

This commit is contained in:
Kittywhiskers Van Gogh 2021-10-28 09:42:13 -03:00
parent f6fa0c06b8
commit 1b241a2832
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
3 changed files with 8 additions and 14 deletions

View File

@ -8,18 +8,12 @@ import os
from test_framework.p2p import P2PInterface from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal from test_framework.util import check_node_connections
INBOUND_CONNECTIONS = 5 INBOUND_CONNECTIONS = 5
BLOCK_RELAY_CONNECTIONS = 2 BLOCK_RELAY_CONNECTIONS = 2
def check_node_connections(*, node, num_in, num_out):
info = node.getnetworkinfo()
assert_equal(info["connections_in"], num_in)
assert_equal(info["connections_out"], num_out)
class AnchorsTest(BitcoinTestFramework): class AnchorsTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1

View File

@ -6,13 +6,7 @@
from test_framework.p2p import P2PInterface from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal from test_framework.util import check_node_connections
def check_node_connections(*, node, num_in, num_out):
info = node.getnetworkinfo()
assert_equal(info["connections_in"], num_in)
assert_equal(info["connections_out"], num_out)
class P2PAddConnections(BitcoinTestFramework): class P2PAddConnections(BitcoinTestFramework):

View File

@ -264,6 +264,7 @@ def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'),
else: else:
return False return False
def sha256sum_file(filename): def sha256sum_file(filename):
h = hashlib.sha256() h = hashlib.sha256()
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
@ -479,6 +480,11 @@ def set_node_times(nodes, t):
node.mocktime = t node.mocktime = t
node.setmocktime(t) node.setmocktime(t)
def check_node_connections(*, node, num_in, num_out):
info = node.getnetworkinfo()
assert_equal(info["connections_in"], num_in)
assert_equal(info["connections_out"], num_out)
def force_finish_mnsync(node): def force_finish_mnsync(node):
""" """