|
14 | 14 | assert_greater_than_or_equal,
|
15 | 15 | )
|
16 | 16 |
|
| 17 | + |
17 | 18 | class WalletEncryptionTest(BitcoinTestFramework):
|
18 | 19 | def set_test_params(self):
|
19 | 20 | self.setup_clean_chain = True
|
@@ -70,20 +71,27 @@ def run_test(self):
|
70 | 71 |
|
71 | 72 | # Test timeout bounds
|
72 | 73 | assert_raises_rpc_error(-8, "Timeout cannot be negative.", self.nodes[0].walletpassphrase, passphrase2, -10)
|
73 |
| - # Check the timeout |
74 |
| - # Check a time less than the limit |
| 74 | + |
| 75 | + self.log.info('Check a timeout less than the limit') |
75 | 76 | MAX_VALUE = 100000000
|
76 | 77 | expected_time = self.mocktime + MAX_VALUE - 600
|
77 | 78 | self.nodes[0].walletpassphrase(passphrase2, MAX_VALUE - 600)
|
| 79 | + self.bump_mocktime(1) |
| 80 | + # give buffer for walletpassphrase, since it iterates over all crypted keys |
| 81 | + expected_time_with_buffer = self.mocktime + MAX_VALUE - 600 |
78 | 82 | actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
|
79 | 83 | assert_greater_than_or_equal(actual_time, expected_time)
|
80 |
| - assert_greater_than(expected_time + 5, actual_time) # 5 second buffer |
81 |
| - # Check a time greater than the limit |
| 84 | + assert_greater_than(expected_time_with_buffer, actual_time) |
| 85 | + |
| 86 | + self.log.info('Check a timeout greater than the limit') |
82 | 87 | expected_time = self.mocktime + MAX_VALUE - 1
|
83 | 88 | self.nodes[0].walletpassphrase(passphrase2, MAX_VALUE + 1000)
|
| 89 | + self.bump_mocktime(1) |
| 90 | + expected_time_with_buffer = self.mocktime + MAX_VALUE |
84 | 91 | actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
|
85 | 92 | assert_greater_than_or_equal(actual_time, expected_time)
|
86 |
| - assert_greater_than(expected_time + 5, actual_time) # 5 second buffer |
| 93 | + assert_greater_than(expected_time_with_buffer, actual_time) |
| 94 | + |
87 | 95 |
|
88 | 96 | if __name__ == '__main__':
|
89 | 97 | WalletEncryptionTest().main()
|
0 commit comments