Skip to content

Conversation

jonatack
Copy link
Member

@jonatack jonatack commented Mar 28, 2019

This pull request adds test coverage in test/functional/tool_wallet.py to reproduce unexpected writes to the wallet as described in #15608 and serve as a benchmark for fixing the issue:

  • 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.

Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

Thanks to Marco Falke for pointing me in the right direction.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 28, 2019

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

Conflicts

No conflicts as of last run.

@DrahtBot DrahtBot added the Tests label Mar 28, 2019
@jonatack jonatack force-pushed the tool-wallet-tests-for-unexpected-writes-to-wallet-file branch from 6d9b033 to 7abd455 Compare April 3, 2019 16:28
jonatack added a commit to jonatack/bitcoin-development that referenced this pull request Apr 4, 2019
Tests were added with bitcoin/bitcoin#15687 so now update todo to resolving the issue.
@jonatack jonatack force-pushed the tool-wallet-tests-for-unexpected-writes-to-wallet-file branch from 7abd455 to 96e69a2 Compare April 5, 2019 10:41
@jonatack
Copy link
Member Author

jonatack commented Apr 5, 2019

Lowered the buffer size for the shasum function to 16Kb and hoisted that value to a constant. Rebased.

This should be ready for review.

@laanwj
Copy link
Member

laanwj commented Jun 17, 2019

Looks good to me
ACK 96e69a2

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

some style-nits

@jonatack jonatack force-pushed the tool-wallet-tests-for-unexpected-writes-to-wallet-file branch from 96e69a2 to 1b286d3 Compare July 2, 2019 19:40
@jonatack
Copy link
Member Author

jonatack commented Jul 2, 2019

Linter is complaining about unused code because it is in the commented-out tests and Appveyor seems to keep file perms at 666. Reworking.

@jonatack jonatack force-pushed the tool-wallet-tests-for-unexpected-writes-to-wallet-file branch 3 times, most recently from d336321 to 497af0c Compare July 3, 2019 10:26
@jonatack
Copy link
Member Author

jonatack commented Jul 8, 2019

Thanks for the review @laanwj and @MarcoFalke. I've pushed rebased commits that address your feedback. Are you able to rereview/retest?

jonatack added 3 commits July 8, 2019 12:33
and update code comments as per Python PEP 8 style guide.
as per Marco Falke review suggestion.
This commit adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#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.

2. Provisionally extend the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

3. Add some logging for sanity checking.

------

Changes after rebase:

5. Make wallet_path an instance method instead of a function in tool_wallet.py as per Marco Falke review suggestion.

6. 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.

7. Change the added logging from info to debug level.

8. 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.
@jonatack jonatack force-pushed the tool-wallet-tests-for-unexpected-writes-to-wallet-file branch from 497af0c to 7195fa7 Compare July 8, 2019 11:24
@laanwj
Copy link
Member

laanwj commented Jul 8, 2019

code review ACK 7195fa7

@laanwj laanwj merged commit 7195fa7 into bitcoin:master Jul 8, 2019
laanwj added a commit that referenced this pull request Jul 8, 2019
…o wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in #15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
@jonatack jonatack deleted the tool-wallet-tests-for-unexpected-writes-to-wallet-file branch July 8, 2019 16:24
@jonatack
Copy link
Member Author

jonatack commented Jul 8, 2019

The lone Travis failure appears to be an unrelated wait_until timeout > 60 sec in feature_block.py.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 9, 2019
…rites to wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 1, 2020
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 bitcoin/bitcoin#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.

2. Provisionally extend the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

3. Add some logging for sanity checking.

------

Changes after rebase:

5. Make wallet_path an instance method instead of a function in tool_wallet.py as per Marco Falke review suggestion.

6. 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.

7. Change the added logging from info to debug level.

8. 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 [[bitcoin/bitcoin#15687 | PR15687]]

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7706
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Dec 6, 2021
…rites to wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Dec 10, 2021
…rites to wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Dec 13, 2021
…rites to wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Dec 13, 2021
…rites to wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Dec 15, 2021
…rites to wallet

7195fa7 test: Tool wallet test coverage for unexpected writes to wallet (Jon Atack)
3bf2b3a test: Split tool_wallet.py test into subtests (Jon Atack)
1eb13f0 test: Add log messages to test/functional/tool_wallet.py (Jon Atack)

Pull request description:

  This pull request adds test coverage in `test/functional/tool_wallet.py` to reproduce unexpected writes to the wallet as described in bitcoin#15608 and serve as a benchmark for fixing the issue:

  - 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.

  Goals:

  1. Reproduce the reported issue, define the current unexpected behavior, and add test coverage to guide a future fix. Add debug-level logging for sanity checking and commented-out assertions to be uncommented when fixing the issue. Add the same coverage to the wallet tool create test and the getwalletinfo test as regression tests while fixing the issue.

  2. Add info log messages as there are currently none in the test file.

  3. Split the tests out to separate functions as per review feedback.

  Thanks to Marco Falke for pointing me in the right direction.

ACKs for top commit:
  laanwj:
    code review ACK 7195fa7

Tree-SHA512: 16a41cce989c8f819cf5b02c6cf8ea84653ede2738fb402f6c36cf4dc075b424dff3e2c73a1cfa1ec9c75f614675baecc71e588845a2596db06ba0957db2df7b
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants