Skip to content

Commit de23739

Browse files
committed
test: Fix rpc_net.py "pong" race condition
Prior to this change, the test fails with KeyError if pong has a zero value at the time this is called, as getpeerinfo's bytesrecv_per_msg result excludes zero-values. https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/21310881#L62
1 parent f5a70d1 commit de23739

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/functional/rpc_net.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def _test_getnettotals(self):
6767

6868
peer_info_after_ping = self.nodes[0].getpeerinfo()
6969
for before, after in zip(peer_info, peer_info_after_ping):
70-
assert_greater_than_or_equal(after['bytesrecv_per_msg']['pong'], before['bytesrecv_per_msg']['pong'] + 32)
71-
assert_greater_than_or_equal(after['bytessent_per_msg']['ping'], before['bytessent_per_msg']['ping'] + 32)
70+
assert_greater_than_or_equal(after['bytesrecv_per_msg'].get('pong', 0), before['bytesrecv_per_msg'].get('pong', 0) + 32)
71+
assert_greater_than_or_equal(after['bytessent_per_msg'].get('ping', 0), before['bytessent_per_msg'].get('ping', 0) + 32)
7272

7373
def _test_getnetworkinginfo(self):
7474
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)

0 commit comments

Comments
 (0)