diff options
author | Ricardo Velhote <rvelhote@gmail.com> | 2017-05-14 19:18:26 +0100 |
---|---|---|
committer | Ricardo Velhote <rvelhote@gmail.com> | 2017-06-25 20:25:45 +0100 |
commit | c07475294ae2c60f1dcc394922838b1f1f57b476 (patch) | |
tree | c319c0083959385a694e7b30ea7f00422c5c82b1 /test/functional | |
parent | d609fd85ca41c003233d74fbd6c680970ad4a48b (diff) |
[RPC] Add an uptime command that displays the amount of time that bitcoind has been running
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/test_runner.py | 1 | ||||
-rwxr-xr-x | test/functional/uptime.py | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 0dca318af8..4c7eea67d5 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -113,6 +113,7 @@ BASE_SCRIPTS= [ 'listsinceblock.py', 'p2p-leaktests.py', 'wallet-encryption.py', + 'uptime.py', ] EXTENDED_SCRIPTS = [ diff --git a/test/functional/uptime.py b/test/functional/uptime.py new file mode 100755 index 0000000000..b20d6f5cb6 --- /dev/null +++ b/test/functional/uptime.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 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 the RPC call related to the uptime command. + +Test corresponds to code in rpc/server.cpp. +""" + +import time + +from test_framework.test_framework import BitcoinTestFramework + + +class UptimeTest(BitcoinTestFramework): + def __init__(self): + super().__init__() + + self.num_nodes = 1 + self.setup_clean_chain = True + + def run_test(self): + self._test_uptime() + + def _test_uptime(self): + wait_time = 10 + self.nodes[0].setmocktime(int(time.time() + wait_time)) + assert(self.nodes[0].uptime() >= wait_time) + + +if __name__ == '__main__': + UptimeTest().main() |