Clamps the timeout of walletpassphrase to 2^(30) seconds, which is ~34 years. Any number greater than that will be forced to be 2^(30). This avoids the sign flipping problem with large values which can result in a negative time used. Also perform bounds checks to ensure that the timeout is positive to avoid immediate relocking of the wallet.
Backport of core PR12101 and PR12905 (fix for OSX)
https://github.com/bitcoin/bitcoin/pull/12101/files
https://github.com/bitcoin/bitcoin/pull/12905/files
Due to the fix from D2633 enabling mocktime, the test will fail using
time.time() as a reference. The mocktime is used instead to get rid of
the issue.