-
Notifications
You must be signed in to change notification settings - Fork 39.2k
wallet: Correct dir iteration error handling #32736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,24 @@ def wallet_file(name): | |
| self.stop_nodes() | ||
| assert_equal(os.path.isfile(wallet_dir(self.default_wallet_name, self.wallet_data_filename)), True) | ||
|
|
||
| self.log.info("Verify warning is emitted when failing to scan the wallets directory") | ||
| if platform.system() == 'Windows': | ||
| self.log.warning('Skipping test involving chmod as Windows does not support it.') | ||
| elif os.geteuid() == 0: | ||
| self.log.warning('Skipping test involving chmod as it requires a non-root user.') | ||
| else: | ||
| self.start_node(0) | ||
| with self.nodes[0].assert_debug_log(unexpected_msgs=['Error scanning directory entries under'], expected_msgs=[]): | ||
| result = self.nodes[0].listwalletdir() | ||
| assert_equal(result, {'wallets': [{'name': 'default_wallet', 'warnings': []}]}) | ||
| os.chmod(data_dir('wallets'), 0) | ||
| with self.nodes[0].assert_debug_log(expected_msgs=['Error scanning directory entries under']): | ||
| result = self.nodes[0].listwalletdir() | ||
| assert_equal(result, {'wallets': []}) | ||
| self.stop_node(0) | ||
| # Restore permissions | ||
| os.chmod(data_dir('wallets'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: - os.chmod(data_dir('wallets'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
+ os.chmod(data_dir('wallets'), stat.S_IRWXU)Initially, I thought of fetching the stat modes from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat! Maybe something that could be done in #31410 now this one merged? |
||
|
|
||
| # create symlink to verify wallet directory path can be referenced | ||
| # through symlink | ||
| os.mkdir(wallet_dir('w7')) | ||
|
|
@@ -129,7 +147,7 @@ def wallet_file(name): | |
| os.mkdir(wallet_dir('no_access')) | ||
| os.chmod(wallet_dir('no_access'), 0) | ||
| try: | ||
| with self.nodes[0].assert_debug_log(expected_msgs=['Error scanning']): | ||
| with self.nodes[0].assert_debug_log(expected_msgs=["Error while scanning wallet dir"]): | ||
| walletlist = self.nodes[0].listwalletdir()['wallets'] | ||
| finally: | ||
| # Need to ensure access is restored for cleanup | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice checking for the effective user ID, was the intention to add it as a safety check?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the test would not pass when this check/skip is removed. See #32736 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To elaborate, we probably run tests under root on CI in some cases to enable tracing:
bitcoin/test/functional/test_framework/test_framework.py
Lines 971 to 975 in 272cd09