Skip to content

Commit 559cb5a

Browse files
fanquakevijaydasmp
authored andcommitted
Merge bitcoin#28671: test: Fix failing time check in rpc_net.py
fa4c683 test: Fix failing time check in rpc_net.py (MarcoFalke) Pull request description: This check fails on slow runners, such as s390x qemu. Fix it by using mocktime. See bitcoin#28523 (comment) ACKs for top commit: 0xB10C: ACK fa4c683 pinheadmz: ACK fa4c683 brunoerg: crACK fa4c683 Tree-SHA512: 83fb534682e11e97537dc89de8c16f206f38af1a892a2d5970c02684c05eaea8fc9adba3159f16b2440ca0b3871d513a0562a6f3a38f19a5574a47be0919e42f
1 parent daa0925 commit 559cb5a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/functional/rpc_net.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2017-2020 The Bitcoin Core developers
2+
# Copyright (c) 2017-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test RPC calls related to net.
66
77
Tests correspond to code in rpc/net.cpp.
88
"""
99

10+
import time
1011
import test_framework.messages
1112
from test_framework.messages import (
1213
MAX_PROTOCOL_MESSAGE_LENGTH,
@@ -352,9 +353,11 @@ def test_addpeeraddress(self):
352353

353354
self.log.debug("Test that adding an address with invalid port fails")
354355
assert_raises_rpc_error(-1, "JSON integer out of range", self.nodes[0].addpeeraddress, address="1.2.3.4", port=-1)
355-
assert_raises_rpc_error(-1, "JSON integer out of range", self.nodes[0].addpeeraddress,address="1.2.3.4", port=65536)
356+
assert_raises_rpc_error(-1, "JSON integer out of range", self.nodes[0].addpeeraddress, address="1.2.3.4", port=65536)
356357

357358
self.log.debug("Test that adding a valid address to the tried table succeeds")
359+
self.addr_time = int(time.time())
360+
node.setmocktime(self.addr_time)
358361
assert_equal(node.addpeeraddress(address="1.2.3.4", tried=True, port=8333), {"success": True})
359362
with node.assert_debug_log(expected_msgs=["CheckAddrman: new 0, tried 1, total 1 started"]):
360363
addrs = node.getnodeaddresses(count=0) # getnodeaddresses re-runs the addrman checks

0 commit comments

Comments
 (0)