Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
Show First 20 Lines • Show All 702 Lines • ▼ Show 20 Lines | def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs): | ||||
# | # | ||||
# So syncing here is redundant when we only want to send a message, but the cost is low (a few milliseconds) | # So syncing here is redundant when we only want to send a message, but the cost is low (a few milliseconds) | ||||
# in comparison to the upside of making tests less fragile and | # in comparison to the upside of making tests less fragile and | ||||
# unexpected intermittent errors less likely. | # unexpected intermittent errors less likely. | ||||
p2p_conn.sync_with_ping() | p2p_conn.sync_with_ping() | ||||
return p2p_conn | return p2p_conn | ||||
@property | |||||
def p2p(self): | |||||
"""Return the first p2p connection | |||||
Convenience property - most tests only use a single p2p connection to each | |||||
node, so this saves having to write node.p2ps[0] many times.""" | |||||
assert self.p2ps, self._node_msg("No p2p connection") | |||||
return self.p2ps[0] | |||||
def num_test_p2p_connections(self): | def num_test_p2p_connections(self): | ||||
"""Return number of test framework p2p connections to the node.""" | """Return number of test framework p2p connections to the node.""" | ||||
return len([peer for peer in self.getpeerinfo() | return len([peer for peer in self.getpeerinfo() | ||||
if peer['subver'] == MY_SUBVERSION]) | if peer['subver'] == MY_SUBVERSION]) | ||||
def disconnect_p2ps(self): | def disconnect_p2ps(self): | ||||
"""Close all p2p connections to the node.""" | """Close all p2p connections to the node.""" | ||||
for p in self.p2ps: | for p in self.p2ps: | ||||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |