Skip to content

Commit 13d7f00

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge bitcoin#19429: test: Fix intermittent failure in wallet_encryption
fabd33b test: Fix intermittent failure in wallet_encryption (MarcoFalke) Pull request description: Iterating all crypted keys might take time. E.g. ``` node0 2020-07-01T14:41:19.227367Z [httpworker.0] ThreadRPCServer method=walletpassphrase user=__cookie__ node0 2020-07-01T14:41:24.377142Z [httpworker.0] queue run of timer lockwallet() in 100000000 seconds (using HTTP) ... test 2020-07-01T14:41:24.379000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 117, in main self.run_test() File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/wallet_encryption.py", line 88, in run_test assert_greater_than(expected_time + 5, actual_time) # 5 second buffer File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/util.py", line 54, in assert_greater_than raise AssertionError("%s <= %s" % (str(thing1), str(thing2))) AssertionError: 1693614483 <= 1693614484 ``` https://cirrus-ci.com/task/5322429885054976?command=ci#L4517 ACKs for top commit: achow101: ACK fabd33b Tree-SHA512: 7a3ccdfc0cdc05fef1f942d3167d100ed63422eb54c05405c884ed91162b7bdb5ce54cb5a981b99a6df2e4af1ea834ccd7d5156531c8c14ea13e735becd6b377
1 parent 0ac06c1 commit 13d7f00

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/functional/wallet_encryption.py

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

17+
1718
class WalletEncryptionTest(BitcoinTestFramework):
1819
def set_test_params(self):
1920
self.setup_clean_chain = True
@@ -70,20 +71,27 @@ def run_test(self):
7071

7172
# Test timeout bounds
7273
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')
7576
MAX_VALUE = 100000000
7677
expected_time = self.mocktime + MAX_VALUE - 600
7778
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
7882
actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
7983
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')
8287
expected_time = self.mocktime + MAX_VALUE - 1
8388
self.nodes[0].walletpassphrase(passphrase2, MAX_VALUE + 1000)
89+
self.bump_mocktime(1)
90+
expected_time_with_buffer = self.mocktime + MAX_VALUE
8491
actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
8592
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+
8795

8896
if __name__ == '__main__':
8997
WalletEncryptionTest().main()

0 commit comments

Comments
 (0)