test: enable v2 for python p2p depending on global --v2transport flag

This changes the default behavior, individual tests can overwrite this option.
As a result, it is possible to run the entire test suite with
--v2transport, and all connections to the python p2p will then use it.

Also adjust several tests that are already running with --v2transport in the
test runner (although they actually made v1 connection before this change).
This is done in the same commit so that there isn't an
intermediate commit in which the CI fails.
This commit is contained in:
Martin Zumsande
2023-11-20 15:10:29 -05:00
parent 6e9e39da43
commit bf5662c678
4 changed files with 34 additions and 21 deletions

View File

@@ -117,6 +117,9 @@ class NetTest(BitcoinTestFramework):
peer_info = self.nodes[0].getpeerinfo()[no_version_peer_id]
peer_info.pop("addr")
peer_info.pop("addrbind")
# The next two fields will vary for v2 connections because we send a rng-based number of decoy messages
peer_info.pop("bytesrecv")
peer_info.pop("bytessent")
assert_equal(
peer_info,
{
@@ -125,9 +128,7 @@ class NetTest(BitcoinTestFramework):
"addr_relay_enabled": False,
"bip152_hb_from": False,
"bip152_hb_to": False,
"bytesrecv": 0,
"bytesrecv_per_msg": {},
"bytessent": 0,
"bytessent_per_msg": {},
"connection_type": "inbound",
"conntime": no_version_peer_conntime,
@@ -136,8 +137,8 @@ class NetTest(BitcoinTestFramework):
"inflight": [],
"last_block": 0,
"last_transaction": 0,
"lastrecv": 0,
"lastsend": 0,
"lastrecv": 0 if not self.options.v2transport else no_version_peer_conntime,
"lastsend": 0 if not self.options.v2transport else no_version_peer_conntime,
"minfeefilter": Decimal("0E-8"),
"network": "not_publicly_routable",
"permissions": [],
@@ -145,13 +146,13 @@ class NetTest(BitcoinTestFramework):
"relaytxes": False,
"services": "0000000000000000",
"servicesnames": [],
"session_id": "",
"session_id": "" if not self.options.v2transport else no_version_peer.v2_state.peer['session_id'].hex(),
"startingheight": -1,
"subver": "",
"synced_blocks": -1,
"synced_headers": -1,
"timeoffset": 0,
"transport_protocol_type": "v1" if not self.options.v2transport else "detecting",
"transport_protocol_type": "v1" if not self.options.v2transport else "v2",
"version": 0,
},
)