Repository: bitcoin/bitcoin
File: test/functional/rpc_net.py (Python)

Code before:
        peer_info.pop("bytessent")
        assert_equal(
            peer_info,
            {
                "addr_processed": 0,
                "addr_rate_limited": 0,
                "addr_relay_enabled": False,
                "bip152_hb_from": False,
                "bip152_hb_to": False,
                "bytesrecv_per_msg": {},
                "bytessent_per_msg": {},
                "connection_type": "inbound",
                "conntime": no_version_peer_conntime,
                "id": no_version_peer_id,
                "inbound": True,
                "inflight": [],
                "last_block": 0,
                "last_transaction": 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": [],
                "presynced_headers": -1,
                "relaytxes": False,
                "services": "0000000000000000",
                "servicesnames": [],
                "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 "v2",
                "version": 0,
            },
        )
        no_version_peer.peer_disconnect()
        self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 2)

    def test_getnettotals(self):
        self.log.info("Test getnettotals")
        # Test getnettotals and getpeerinfo by doing a ping. The bytes
        # sent/received should increase by at least the size of one ping
        # and one pong. Both have a payload size of 8 bytes, but the total
        # size depends on the used p2p version:
        #   - p2p v1: 24 bytes (header) + 8 bytes (payload) = 32 bytes
        #   - p2p v2: 21 bytes (header/tag with short-id) + 8 bytes (payload) = 29 bytes
        ping_size = 32 if not self.options.v2transport else 29
        net_totals_before = self.nodes[0].getnettotals()
        peer_info_before = self.nodes[0].getpeerinfo()

Review comment (bug):
The CI failures indicate that we need to add the other field as well:
```suggestion
                "last_inv_sequence": 0,
                "inv_to_send": 0,
```
---
tested locally that it fixes the tests:
```
TEST                     | STATUS    | DURATION

rpc_net.py --v1transport | ✓ Passed  | 12 s
rpc_net.py --v2transport | ✓ Passed  | 10 s  
```

Code after:
        peer_info.pop("bytessent")
        assert_equal(
            peer_info,
            {
                "addr_processed": 0,
                "addr_rate_limited": 0,
                "addr_relay_enabled": False,
                "bip152_hb_from": False,
                "bip152_hb_to": False,
                "bytesrecv_per_msg": {},
                "bytessent_per_msg": {},
                "connection_type": "inbound",
                "conntime": no_version_peer_conntime,
                "id": no_version_peer_id,
                "inbound": True,
                "inflight": [],
                "last_block": 0,
                "last_transaction": 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": [],
                "presynced_headers": -1,
                "relaytxes": False,
                "inv_to_send": 0,
                "last_inv_sequence": 0,
                "services": "0000000000000000",
                "servicesnames": [],
                "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 "v2",
                "version": 0,
            },
        )
        no_version_peer.peer_disconnect()
        self.wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 2)

    def test_getnettotals(self):
        self.log.info("Test getnettotals")
        # Test getnettotals and getpeerinfo by doing a ping. The bytes
        # sent/received should increase by at least the size of one ping
        # and one pong. Both have a payload size of 8 bytes, but the total
        # size depends on the used p2p version:
        #   - p2p v1: 24 bytes (header) + 8 bytes (payload) = 32 bytes
        #   - p2p v2: 21 bytes (header/tag with short-id) + 8 bytes (payload) = 29 bytes
        ping_size = 32 if not self.options.v2transport else 29