Page MenuHomePhabricator

Avoid UBSan warning in ProcessMessage(...) and disallow negative mocktime
ClosedPublic

Authored by PiRK on Jul 22 2022, 07:19.

Details

Summary

This is a backport of core#21043

Most of the work was already done in D6022. The functional test already exists in abc_rpc_mocktime.py, only the error messages need to be updated.

Test Plan
ninja all check-all
src/bitcoin-cli help setmocktime

Event Timeline

PiRK requested review of this revision.Jul 22 2022, 07:19
PiRK planned changes to this revision.Jul 22 2022, 07:20

need to merge with existing test from D6022

Failed tests logs:

====== Bitcoin ABC functional tests: abc_rpc_mocktime.py ======

------- Stdout: -------
2022-07-22T07:30:40.463000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20220722_072359/abc_rpc_mocktime_163
2022-07-22T07:30:40.996000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/util.py", line 148, in try_rpc
    fun(*args, **kwds)
  File "/work/test/functional/test_framework/coverage.py", line 47, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 163, in __call__
    raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: Mocktime can not be negative: -1. (-8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/abc_rpc_mocktime.py", line 22, in run_test
    self.nodes[0].setmocktime, -1)
  File "/work/test/functional/test_framework/util.py", line 139, in assert_raises_rpc_error
    assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
  File "/work/test/functional/test_framework/util.py", line 158, in try_rpc
    message, e.error['message']))
AssertionError: Expected substring not found in error message:
substring: 'Timestamp must be 0 or greater'
error message: 'Mocktime can not be negative: -1.'.
2022-07-22T07:30:41.047000Z TestFramework (INFO): Stopping nodes
2022-07-22T07:30:41.248000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20220722_072359/abc_rpc_mocktime_163
2022-07-22T07:30:41.248000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20220722_072359/abc_rpc_mocktime_163/test_framework.log
2022-07-22T07:30:41.248000Z TestFramework (ERROR): 
2022-07-22T07:30:41.248000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20220722_072359/abc_rpc_mocktime_163' to consolidate all logs
2022-07-22T07:30:41.248000Z TestFramework (ERROR): 
2022-07-22T07:30:41.248000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2022-07-22T07:30:41.248000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2022-07-22T07:30:41.248000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_rpc_mocktime.py

Failed tests logs:

====== Bitcoin ABC functional tests: abc_rpc_mocktime.py ======

------- Stdout: -------
2022-07-22T07:32:16.417000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20220722_072951/abc_rpc_mocktime_163
2022-07-22T07:32:16.676000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/util.py", line 148, in try_rpc
    fun(*args, **kwds)
  File "/work/test/functional/test_framework/coverage.py", line 47, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 163, in __call__
    raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: Mocktime can not be negative: -1. (-8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/abc_rpc_mocktime.py", line 22, in run_test
    self.nodes[0].setmocktime, -1)
  File "/work/test/functional/test_framework/util.py", line 139, in assert_raises_rpc_error
    assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
  File "/work/test/functional/test_framework/util.py", line 158, in try_rpc
    message, e.error['message']))
AssertionError: Expected substring not found in error message:
substring: 'Timestamp must be 0 or greater'
error message: 'Mocktime can not be negative: -1.'.
2022-07-22T07:32:16.727000Z TestFramework (INFO): Stopping nodes
2022-07-22T07:32:16.878000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20220722_072951/abc_rpc_mocktime_163
2022-07-22T07:32:16.878000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20220722_072951/abc_rpc_mocktime_163/test_framework.log
2022-07-22T07:32:16.878000Z TestFramework (ERROR): 
2022-07-22T07:32:16.878000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-without-wallet/test/tmp/test_runner_₿₵_  _20220722_072951/abc_rpc_mocktime_163' to consolidate all logs
2022-07-22T07:32:16.878000Z TestFramework (ERROR): 
2022-07-22T07:32:16.878000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2022-07-22T07:32:16.878000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2022-07-22T07:32:16.879000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_rpc_mocktime.py

PiRK edited the summary of this revision. (Show Details)

merge abc_rpc_mocktime.py and rpc_uptime.py

Failed tests logs:

====== Bitcoin ABC functional tests: abc_rpc_mocktime.py ======

------- Stdout: -------
2022-07-22T07:35:18.596000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073042/abc_rpc_mocktime_163
2022-07-22T07:35:18.947000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/util.py", line 148, in try_rpc
    fun(*args, **kwds)
  File "/work/test/functional/test_framework/coverage.py", line 47, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 163, in __call__
    raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: Mocktime can not be negative: -1. (-8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/abc_rpc_mocktime.py", line 22, in run_test
    self.nodes[0].setmocktime, -1)
  File "/work/test/functional/test_framework/util.py", line 139, in assert_raises_rpc_error
    assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
  File "/work/test/functional/test_framework/util.py", line 158, in try_rpc
    message, e.error['message']))
AssertionError: Expected substring not found in error message:
substring: 'Timestamp must be 0 or greater'
error message: 'Mocktime can not be negative: -1.'.
2022-07-22T07:35:19.001000Z TestFramework (INFO): Stopping nodes
2022-07-22T07:35:19.655000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073042/abc_rpc_mocktime_163
2022-07-22T07:35:19.655000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073042/abc_rpc_mocktime_163/test_framework.log
2022-07-22T07:35:19.655000Z TestFramework (ERROR): 
2022-07-22T07:35:19.656000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073042/abc_rpc_mocktime_163' to consolidate all logs
2022-07-22T07:35:19.656000Z TestFramework (ERROR): 
2022-07-22T07:35:19.656000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2022-07-22T07:35:19.657000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2022-07-22T07:35:19.657000Z TestFramework (ERROR):
====== Bitcoin ABC functional tests with the next upgrade activated: abc_rpc_mocktime.py ======

------- Stdout: -------
2022-07-22T07:39:54.229000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073538/abc_rpc_mocktime_163
2022-07-22T07:39:54.511000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/util.py", line 148, in try_rpc
    fun(*args, **kwds)
  File "/work/test/functional/test_framework/coverage.py", line 47, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 163, in __call__
    raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: Mocktime can not be negative: -1. (-8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/abc_rpc_mocktime.py", line 22, in run_test
    self.nodes[0].setmocktime, -1)
  File "/work/test/functional/test_framework/util.py", line 139, in assert_raises_rpc_error
    assert try_rpc(code, message, fun, *args, **kwds), "No exception raised"
  File "/work/test/functional/test_framework/util.py", line 158, in try_rpc
    message, e.error['message']))
AssertionError: Expected substring not found in error message:
substring: 'Timestamp must be 0 or greater'
error message: 'Mocktime can not be negative: -1.'.
2022-07-22T07:39:54.562000Z TestFramework (INFO): Stopping nodes
2022-07-22T07:39:54.713000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073538/abc_rpc_mocktime_163
2022-07-22T07:39:54.714000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073538/abc_rpc_mocktime_163/test_framework.log
2022-07-22T07:39:54.714000Z TestFramework (ERROR): 
2022-07-22T07:39:54.714000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220722_073538/abc_rpc_mocktime_163' to consolidate all logs
2022-07-22T07:39:54.714000Z TestFramework (ERROR): 
2022-07-22T07:39:54.714000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2022-07-22T07:39:54.714000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2022-07-22T07:39:54.714000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_rpc_mocktime.py
Bitcoin ABC functional tests with the next upgrade activated: abc_rpc_mocktime.py

Fabien requested changes to this revision.Jul 22 2022, 08:08
Fabien added a subscriber: Fabien.

Don't merge the tests, they are totally unrelated.

This revision now requires changes to proceed.Jul 22 2022, 08:08
PiRK edited the summary of this revision. (Show Details)

Unmerge the test. No need to duplicate this test, though, so don't put it in rpc_uptime.py

This revision is now accepted and ready to land.Jul 22 2022, 09:39