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