QA: Fix race condition in wallet_encryption test #16420

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2019/07/wallet_enc_test_fix changing 1 files +1 −1
  1. jonasschnelli commented at 8:32 PM on July 18, 2019: contributor

    There is some imprecision probably in the internal HTTPRPCTimer class (haven't exactly figured out where). But we can't expect that waiting excatly 2 seconds right after calling walletpassphrase(2) will result in a locked wallet due to the nature how we internally handle threads/timers.

    The wallet_encryption test fails regularely in CIs.

    Here is a logged session:

     node0 2019-07-18T18:51:22.569739Z [] ThreadRPCServer method=walletpassphrase user=__cookie__ 
     node0 2019-07-18T18:51:22.628656Z [] queue run of timer lockwallet() in 2 seconds (using HTTP) 
     node0 2019-07-18T18:51:22.629002Z [] Received a POST request for / from 127.0.0.1:46898 
     node0 2019-07-18T18:51:22.629081Z [] ThreadRPCServer method=dumpprivkey user=__cookie__ 
     node0 2019-07-18T18:51:24.445620Z [] Flushing wallet.dat 
     node0 2019-07-18T18:51:24.451421Z [] Flushed wallet.dat 6ms 
     node0 2019-07-18T18:51:24.631703Z [] Received a POST request for / from 127.0.0.1:46898 
     node0 2019-07-18T18:51:24.631737Z [] ThreadRPCServer method=dumpprivkey user=__cookie__ 
     test  2019-07-18T18:51:24.632000Z TestFramework (ERROR): Assertion failed 
                                       Traceback (most recent call last):
                                         File "/home/ubuntu/src/test/functional/test_framework/test_framework.py", line 193, in main
                                           self.run_test()
                                         File "/home/ubuntu/src/test/functional/wallet_encryption.py", line 53, in run_test
                                           assert_raises_rpc_error(-13, "Please enter the wallet passphrase with walletpassphrase first", self.nodes[0].dumpprivkey, address)
    
  2. QA: Fix race condition in wallet_encryption test 024ecd7e01
  3. jonasschnelli added the label Tests on Jul 18, 2019
  4. promag commented at 8:54 PM on July 18, 2019: member

    ACK 024ecd7e01d436ad7de608e571a20c7284b3951b, simple fix, one second shouldn't hurt.

    An alternative is to lower to 1 second the lock timeout in line 48:

    self.nodes[0].walletpassphrase(passphrase, 1)
    

    A more robust alternative is to:

    • wait_until with a predicate that returns True when walletpassphrase raises an exception;
    • and make wait_until return the elapsed time so that the test could assert it is greater than 2 seconds.
  5. MarcoFalke commented at 8:58 PM on July 18, 2019: member

    ACK 024ecd7e01d436ad7de608e571a20c7284b3951b

  6. fanquake approved
  7. fanquake commented at 1:06 AM on July 19, 2019: member

    ACK 024ecd7e01d436ad7de608e571a20c7284b3951b

  8. fanquake merged this on Jul 19, 2019
  9. fanquake closed this on Jul 19, 2019

  10. fanquake referenced this in commit 89d7229c9c on Jul 19, 2019
  11. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-24 12:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me