diff options
author | Andrew Chow <achow101-github@achow101.com> | 2022-08-19 13:51:39 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2022-08-19 13:51:39 -0400 |
commit | 02dea9a47fa17e977c9de72233ebd74e913fa30a (patch) | |
tree | 4e7efd21b862e32c5e3836fcc4ebb989c63dea97 /test/functional | |
parent | 6b56873b41974ced7aad87a4b38abe360c34eed3 (diff) | |
download | bitcoin-02dea9a47fa17e977c9de72233ebd74e913fa30a.tar.xz |
tests: Use mocktime for wallet encryption timeout
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/wallet_encryption.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/test/functional/wallet_encryption.py b/test/functional/wallet_encryption.py index 0c9106f800..37c1c4bff3 100755 --- a/test/functional/wallet_encryption.py +++ b/test/functional/wallet_encryption.py @@ -9,8 +9,7 @@ import time from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_raises_rpc_error, - assert_greater_than, - assert_greater_than_or_equal, + assert_equal, ) @@ -76,21 +75,18 @@ class WalletEncryptionTest(BitcoinTestFramework): self.log.info('Check a timeout less than the limit') MAX_VALUE = 100000000 - expected_time = int(time.time()) + MAX_VALUE - 600 + now = int(time.time()) + self.nodes[0].setmocktime(now) + expected_time = now + MAX_VALUE - 600 self.nodes[0].walletpassphrase(passphrase2, MAX_VALUE - 600) - # give buffer for walletpassphrase, since it iterates over all encrypted keys - expected_time_with_buffer = time.time() + MAX_VALUE - 600 actual_time = self.nodes[0].getwalletinfo()['unlocked_until'] - assert_greater_than_or_equal(actual_time, expected_time) - assert_greater_than(expected_time_with_buffer, actual_time) + assert_equal(actual_time, expected_time) self.log.info('Check a timeout greater than the limit') - expected_time = int(time.time()) + MAX_VALUE - 1 + expected_time = now + MAX_VALUE self.nodes[0].walletpassphrase(passphrase2, MAX_VALUE + 1000) - expected_time_with_buffer = time.time() + MAX_VALUE actual_time = self.nodes[0].getwalletinfo()['unlocked_until'] - assert_greater_than_or_equal(actual_time, expected_time) - assert_greater_than(expected_time_with_buffer, actual_time) + assert_equal(actual_time, expected_time) if __name__ == '__main__': |