Page MenuHomePhabricator

test: tool wallet test coverage for unexpected writes to wallet
ClosedPublic

Authored by deadalnix on Oct 1 2020, 13:39.

Details

Summary
  • test: Add log messages to test/functional/tool_wallet.py

and update code comments as per Python PEP 8 style guide.

  • test: Split tool_wallet.py test into subtests

as per Marco Falke review suggestion.

  • test: Tool wallet test coverage for unexpected writes to wallet

This commit adds test coverage in test/functional/tool_wallet.py to reproduce unexpected writes to the wallet as described in https://github.com/bitcoin/bitcoin/issues/15608:

  • wallet tool info unexpectedly writes to the wallet file if the wallet file permissions are read/write.
  • wallet tool info raises with "Error loading . Is wallet being used by another process?" if the wallet file permissions are read-only.
  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix in the form of commented-out assertions to be uncommented when testing/fixing.
  1. Provisionally extend the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.
  1. Add some logging for sanity checking.

Changes after rebase:

  1. Make wallet_path an instance method instead of a function in tool_wallet.py as per Marco Falke review suggestion.
  1. Assert wallet permissions instead of logging them in tool_wallet.py. This ran into an issue with Appveyor keeping permissions at 666 so allowed for 666 as a workaround.
  1. Change the added logging from info to debug level.
  1. More helpful assertions order in tool_wallet.py#assert_tool_output. This change makes #assert_tool_output raise "Error loading wallet.dat. Is wallet being used by another process?" rather than a less-helpful message when debugging the read-only wallet permissions issue.

This is a backport of Core PR15687

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

This revision is now accepted and ready to land.Oct 1 2020, 13:48
This revision was landed with ongoing or failed builds.Oct 1 2020, 14:16
This revision was automatically updated to reflect the committed changes.

Snippet of first build failure:

[348/409] bitcoin: testing settings_tests
[349/409] Running utility command for check-bitcoin-torcontrol_tests
[350/409] Running utility command for check-bitcoin-settings_tests
[351/409] bitcoin: testing checkdatasig_tests
[352/409] bitcoin: testing streams_tests
[353/409] bitcoin: testing timedata_tests
[354/409] Running utility command for check-bitcoin-checkdatasig_tests
[355/409] Running utility command for check-bitcoin-streams_tests
[356/409] Running utility command for check-bitcoin-timedata_tests
[357/409] bitcoin: testing uint256_tests
[358/409] bitcoin: testing undo_tests
[359/409] Running utility command for check-bitcoin-uint256_tests
[360/409] Running utility command for check-bitcoin-undo_tests
[361/409] bitcoin: testing walletdb_tests
[362/409] Running utility command for check-bitcoin-walletdb_tests
[363/409] bitcoin: testing util_threadnames_tests
[364/409] Running utility command for check-bitcoin-util_threadnames_tests
[365/409] bitcoin: testing sigencoding_tests
[366/409] bitcoin: testing serialize_tests
[367/409] Running utility command for check-bitcoin-sigencoding_tests
[368/409] Running utility command for check-bitcoin-serialize_tests
[369/409] bitcoin: testing script_standard_tests
[370/409] bitcoin: testing blockcheck_tests
[371/409] Running utility command for check-bitcoin-script_standard_tests
[372/409] bitcoin: testing radix_tests
[373/409] Running utility command for check-bitcoin-blockcheck_tests
[374/409] Running utility command for check-bitcoin-radix_tests
[375/409] bitcoin: testing crypto_tests
[376/409] bitcoin: testing blockstatus_tests
[377/409] bitcoin: testing ismine_tests
[378/409] Running utility command for check-bitcoin-crypto_tests
[379/409] Running utility command for check-bitcoin-blockstatus_tests
[380/409] bitcoin: testing cashaddr_tests
[381/409] Running utility command for check-bitcoin-ismine_tests
[382/409] bitcoin: testing validation_block_tests
[383/409] Running utility command for check-bitcoin-cashaddr_tests
[384/409] Running utility command for check-bitcoin-validation_block_tests
[385/409] bitcoin: testing versionbits_tests
[386/409] Running utility command for check-bitcoin-versionbits_tests
[387/409] bitcoin: testing validation_tests
[388/409] bitcoin: testing getarg_tests
[389/409] bitcoin: testing bswap_tests
[390/409] Running utility command for check-bitcoin-validation_tests
[391/409] Running utility command for check-bitcoin-getarg_tests
[392/409] Running utility command for check-bitcoin-bswap_tests
[393/409] bitcoin: testing script_tests
[394/409] Running utility command for check-bitcoin-script_tests
[395/409] bitcoin: testing skiplist_tests
[396/409] Running utility command for check-bitcoin-skiplist_tests
[397/409] bitcoin: testing util_tests
[398/409] Running utility command for check-bitcoin-util_tests
[399/409] bitcoin: testing op_reversebytes_tests
[400/409] Running utility command for check-bitcoin-op_reversebytes_tests
[401/409] bitcoin: testing cuckoocache_tests
[402/409] Running utility command for check-bitcoin-cuckoocache_tests
[403/409] bitcoin: testing coins_tests
[404/409] Running utility command for check-bitcoin-coins_tests
[405/409] bitcoin: testing transaction_tests
[406/409] Running utility command for check-bitcoin-transaction_tests
Build build-clang timed out after 1200.0s