Skip to content

Commit fabd33b

Browse files
author
MarcoFalke
committed
test: Fix intermittent failure in wallet_encryption
1 parent 501203a commit fabd33b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/functional/wallet_encryption.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
assert_greater_than_or_equal,
1414
)
1515

16+
1617
class WalletEncryptionTest(BitcoinTestFramework):
1718
def set_test_params(self):
1819
self.setup_clean_chain = True
@@ -72,20 +73,25 @@ def run_test(self):
7273

7374
# Test timeout bounds
7475
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')
7778
MAX_VALUE = 100000000
7879
expected_time = int(time.time()) + MAX_VALUE - 600
7980
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
8083
actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
8184
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')
8488
expected_time = int(time.time()) + MAX_VALUE - 1
8589
self.nodes[0].walletpassphrase(passphrase2, MAX_VALUE + 1000)
90+
expected_time_with_buffer = time.time() + MAX_VALUE
8691
actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
8792
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+
8995

9096
if __name__ == '__main__':
9197
WalletEncryptionTest().main()

0 commit comments

Comments
 (0)