Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32# Copyright (c) 2017-present The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5"""Test the RPC call related to the uptime command.7Test corresponds to code in rpc/server.cpp.8"""10import time12from test_framework.test_framework import BitcoinTestFramework15class UptimeTest(BitcoinTestFramework):16def set_test_params(self):17self.num_nodes = 118self.setup_clean_chain = True20def run_test(self):21self._test_uptime()23def _test_uptime(self):24time.sleep(1) # Do some work before checking uptime25uptime_before = self.nodes[0].uptime()26assert uptime_before > 0, "uptime should begin at app start"28wait_time = 20_00029self.nodes[0].setmocktime(int(time.time()) + wait_time)30uptime_after = self.nodes[0].uptime()31self.nodes[0].setmocktime(0)32assert uptime_after - uptime_before < wait_time, "uptime should not jump with wall clock"35if __name__ == '__main__':36UptimeTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.