mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-11 03:53:22 +02:00
util: Disallow negative mocktime
Signed-off-by: practicalswift <practicalswift@users.noreply.github.com>
This commit is contained in:
committed by
practicalswift
parent
f5f2f97168
commit
3ddbf22ed1
@@ -10,6 +10,7 @@ Test corresponds to code in rpc/server.cpp.
|
||||
import time
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_raises_rpc_error
|
||||
|
||||
|
||||
class UptimeTest(BitcoinTestFramework):
|
||||
@@ -18,8 +19,12 @@ class UptimeTest(BitcoinTestFramework):
|
||||
self.setup_clean_chain = True
|
||||
|
||||
def run_test(self):
|
||||
self._test_negative_time()
|
||||
self._test_uptime()
|
||||
|
||||
def _test_negative_time(self):
|
||||
assert_raises_rpc_error(-8, "Mocktime can not be negative: -1.", self.nodes[0].setmocktime, -1)
|
||||
|
||||
def _test_uptime(self):
|
||||
wait_time = 10
|
||||
self.nodes[0].setmocktime(int(time.time() + wait_time))
|
||||
|
Reference in New Issue
Block a user