Skip to content

Conversation

jonatack
Copy link
Member

@jonatack jonatack commented Jul 20, 2023

  1. Create file permission utilities in the functional test framework based on test: Add unit & functional test coverage for blockstore #27850 and test: tool wallet test coverage for unexpected writes to wallet #15687.

  2. PR test: tool wallet test coverage for unexpected writes to wallet #15687 added test coverage in test/functional/tool_wallet.py to reproduce unexpected writes to the wallet file, as described in issue Feature request: bitcoin-wallet tool: don't modify files unless requested #15608:

    • wallet tool info unexpectedly writes to the wallet file if the wallet file permissions are read/write
    • wallet tool info raises if the wallet file permissions are read-only

    Update these tests/docs for the following changes:

    • addition of descriptor wallets
    • CI migration away from Appveyor
    • allow running tests that need to change file permissions on Linux using chattr

    Instead of describing the error messages for legacy BDB wallets and descriptor SQLite wallets in a comment, check that the error message is thrown at runtime and document that it shouldn't throw.

  3. Update feature_reindex_readonly.py to use the file permission utilities.

  4. Improve wallet_multiwallet.py coverage, while updating to use the file permission utilities, which enables the test to work on Linux and provides logging and error handling. Also add a log entry for the test.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 20, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28660 (test: enable reindex readonly test on *BSD by pinheadmz)
  • #28550 (Covenant tools softfork by jamesob)
  • #10102 (Multiprocess bitcoin by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot DrahtBot added the Tests label Jul 20, 2023
@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch from d6c11d4 to 079337c Compare July 20, 2023 20:39
@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch from 079337c to 4a5c004 Compare July 20, 2023 23:02
@jonatack
Copy link
Member Author

Pulled in 2 commits from #27850 by @pinheadmz that this is now based on. Will rebase once that PR is merged.

@fanquake
Copy link
Member

fanquake commented Aug 1, 2023

Will rebase once that PR is merged.

Mark as draft for now then, if based on another PR?

@jonatack jonatack marked this pull request as draft August 1, 2023 16:09
@jonatack
Copy link
Member Author

Will rebase and update once #27850 is merged.

@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch 2 times, most recently from 171a82e to 209142f Compare September 29, 2023 21:31
@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch 2 times, most recently from 1a99a9e to 7534d69 Compare September 29, 2023 22:21
@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch 4 times, most recently from 6bba596 to 5e0445c Compare September 30, 2023 19:31
@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch from 5e0445c to 3ac8635 Compare September 30, 2023 21:51
@jonatack jonatack marked this pull request as ready for review October 1, 2023 01:04
@jonatack
Copy link
Member Author

jonatack commented Oct 1, 2023

Rebased and reworked following the merge of #27850 by extracting the chmod+chattr code to a test framework utility (also using the changes in #28545), then using that for the test files that need to change permissions.

@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch from 3ac8635 to d801f46 Compare October 2, 2023 13:14
@jonatack
Copy link
Member Author

jonatack commented Oct 2, 2023

Rebased following the merge of #28545.

self.log.warning("Return early on Linux under root, because chattr failed.")
self.log.warning("This should only happen due to missing capabilities in a container.")
self.log.warning("Make sure to --cap-add LINUX_IMMUTABLE if you want to run this test.")
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing this return will just re-introduce the bug that was fixed when adding it, no?

Copy link
Member Author

@jonatack jonatack Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for having a look! Is this better now? git range-diff 04265ba d801f46 571eb17 (rebased for an unrelated CI failure now fixed in master).

An alternative would be to fail loudly by raising.

@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch 2 times, most recently from ccf2bfd to 571eb17 Compare October 9, 2023 22:27
@jonatack
Copy link
Member Author

Rebased for an unrelated CI failure normally now fixed in master.

PR 15687 added test coverage in test/functional/tool_wallet.py to reproduce
unexpected writes to the wallet file, as described in issue 15608:

- wallet tool info unexpectedly writes to the wallet file if the wallet file permissions are read/write
- wallet tool info raises if the wallet file permissions are read-only

Update these tests for two changes since PR 15687:

- the CI migration away from Appveyor
- the addition of descriptor wallets

Instead of describing the error messages for legacy BDB wallets and descriptor
SQLite wallets in a comment, check that the error message is thrown at runtime
and document that it shouldn't throw.
which enables the test to work on linux and provides the logging and error
handling contained in the utils.

Also add a log entry for the test.
@jonatack jonatack force-pushed the 2023-07-tool-wallet-test-readonly-updates branch from 571eb17 to 6b20d56 Compare October 16, 2023 19:11
@jonatack
Copy link
Member Author

Rebased and updated a line due to a python linter conflict following the merge of #28392.

@pinheadmz, @maflcko, @achow101, @ns-xvrn you might be interested in the changes here.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

if platform.system() == "Linux":
attr = "+i" if readonly else "-i"
try:
subprocess.run(["chattr", attr, filename], capture_output=readonly, check=readonly)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to address this feedback while updating and rebasing for the merge of that pull: #28660 (comment)

@DrahtBot
Copy link
Contributor

⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@jonatack
Copy link
Member Author

jonatack commented Apr 8, 2024

Closing to be able to re-open it.

@jonatack jonatack closed this Apr 8, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Apr 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants