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:
0--- a/test/functional/rpc_net.py
1+++ b/test/functional/rpc_net.py
2@@ -113,11 +113,10 @@ class NetTest(BitcoinTestFramework):
3 self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytessent'] >= net_totals_before['totalbytessent'] + 32 * 2), timeout=1)
4 self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytesrecv'] >= net_totals_before['totalbytesrecv'] + 32 * 2), timeout=1)
5
6- for peer_id in [p['id'] for p in peer_info_before]:
7- before = next(p for p in peer_info_before if p['id'] == peer_id)
8- after = lambda: next(p for p in self.nodes[0].getpeerinfo() if p['id'] == peer_id)
9- self.wait_until(lambda: after()['bytesrecv_per_msg'].get('pong', 0) >= before['bytesrecv_per_msg'].get('pong', 0) + 32, timeout=1)
10- self.wait_until(lambda: after()['bytessent_per_msg'].get('ping', 0) >= before['bytessent_per_msg'].get('ping', 0) + 32, timeout=1)
11+ for peer_before in peer_info_before:
12+ peer_after = lambda: next(p for p in self.nodes[0].getpeerinfo() if p['id'] == peer_before['id'])
13+ self.wait_until(lambda: peer_after()['bytesrecv_per_msg'].get('pong', 0) >= peer_before['bytesrecv_per_msg'].get('pong', 0) + 32, timeout=1)
14+ self.wait_until(lambda: peer_after()['bytessent_per_msg'].get('ping', 0) >= peer_before['bytessent_per_msg'].get('ping', 0) + 32, timeout=1)
15
16 def test_getnetworkinfo(self):
17 self.log.info("Test getnetworkinfo")
Labels
Tests