The test fails because getpeerinfo and getnettotals are not synchronised, so a wait_until is needed for each RPC (separately).
Fixes https://cirrus-ci.com/task/4663366629195776?command=ci#L5034
The test fails because getpeerinfo and getnettotals are not synchronised, so a wait_until is needed for each RPC (separately).
Fixes https://cirrus-ci.com/task/4663366629195776?command=ci#L5034
utACK face870a8a
Thanks for fixing this!
I don't quite understand the "get the id from the peer info and then get the peer info from the id" step. Could be simplified with:
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -113,11 +113,10 @@ class NetTest(BitcoinTestFramework):
self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytessent'] >= net_totals_before['totalbytessent'] + 32 * 2), timeout=1)
self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytesrecv'] >= net_totals_before['totalbytesrecv'] + 32 * 2), timeout=1)
- for peer_id in [p['id'] for p in peer_info_before]:
- before = next(p for p in peer_info_before if p['id'] == peer_id)
- after = lambda: next(p for p in self.nodes[0].getpeerinfo() if p['id'] == peer_id)
- self.wait_until(lambda: after()['bytesrecv_per_msg'].get('pong', 0) >= before['bytesrecv_per_msg'].get('pong', 0) + 32, timeout=1)
- self.wait_until(lambda: after()['bytessent_per_msg'].get('ping', 0) >= before['bytessent_per_msg'].get('ping', 0) + 32, timeout=1)
+ for peer_before in peer_info_before:
+ peer_after = lambda: next(p for p in self.nodes[0].getpeerinfo() if p['id'] == peer_before['id'])
+ self.wait_until(lambda: peer_after()['bytesrecv_per_msg'].get('pong', 0) >= peer_before['bytesrecv_per_msg'].get('pong', 0) + 32, timeout=1)
+ self.wait_until(lambda: peer_after()['bytessent_per_msg'].get('ping', 0) >= peer_before['bytessent_per_msg'].get('ping', 0) + 32, timeout=1)
def test_getnetworkinfo(self):
self.log.info("Test getnetworkinfo")
utACK fa2ecadd0d3283a89d27772dc0275e76277ae17e