aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-10-19 09:32:12 +0100
committerfanquake <fanquake@gmail.com>2023-10-19 09:46:28 +0100
commitf4049eaf08b6c5354e7e8a11c8d78aaeab4c595f (patch)
treef9db979ad3e84d23e222cf37f17e6a7e5c5dcce5 /test/functional
parent655dc716aa6043613171a1338e22928de89a7d3e (diff)
parentfa4c6836c9366c3cc575cb386a397840d5f1aa57 (diff)
downloadbitcoin-f4049eaf08b6c5354e7e8a11c8d78aaeab4c595f.tar.xz
Merge bitcoin/bitcoin#28671: test: Fix failing time check in rpc_net.py
fa4c6836c9366c3cc575cb386a397840d5f1aa57 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 https://github.com/bitcoin/bitcoin/pull/28523#discussion_r1357980527 ACKs for top commit: 0xB10C: ACK fa4c6836c9366c3cc575cb386a397840d5f1aa57 pinheadmz: ACK fa4c6836c9366c3cc575cb386a397840d5f1aa57 brunoerg: crACK fa4c6836c9366c3cc575cb386a397840d5f1aa57 Tree-SHA512: 83fb534682e11e97537dc89de8c16f206f38af1a892a2d5970c02684c05eaea8fc9adba3159f16b2440ca0b3871d513a0562a6f3a38f19a5574a47be0919e42f
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/rpc_net.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 44b86662ea..50a022fc7e 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# Copyright (c) 2017-2022 The Bitcoin Core developers
+# Copyright (c) 2017-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPC calls related to net.
@@ -315,9 +315,11 @@ class NetTest(BitcoinTestFramework):
self.log.debug("Test that adding an address with invalid port fails")
assert_raises_rpc_error(-1, "JSON integer out of range", self.nodes[0].addpeeraddress, address="1.2.3.4", port=-1)
- assert_raises_rpc_error(-1, "JSON integer out of range", self.nodes[0].addpeeraddress,address="1.2.3.4", port=65536)
+ assert_raises_rpc_error(-1, "JSON integer out of range", self.nodes[0].addpeeraddress, address="1.2.3.4", port=65536)
self.log.debug("Test that adding a valid address to the tried table succeeds")
+ self.addr_time = int(time.time())
+ node.setmocktime(self.addr_time)
assert_equal(node.addpeeraddress(address="1.2.3.4", tried=True, port=8333), {"success": True})
with node.assert_debug_log(expected_msgs=["CheckAddrman: new 0, tried 1, total 1 started"]):
addrs = node.getnodeaddresses(count=0) # getnodeaddresses re-runs the addrman checks
@@ -402,8 +404,7 @@ class NetTest(BitcoinTestFramework):
assert_equal(result["network"], expected["network"])
assert_equal(result["source"], expected["source"])
assert_equal(result["source_network"], expected["source_network"])
- # To avoid failing on slow test runners, use a 10s vspan here.
- assert_approx(result["time"], time.time(), vspan=10)
+ assert_equal(result["time"], self.addr_time)
def check_getrawaddrman_entries(expected):
"""Utility to compare a getrawaddrman result with expected addrman contents"""