Skip to content

test: Avoid duplicate curl call in get_previous_releases.py - #30703

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
maflcko:2408-test-less-curl
Aug 24, 2024
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
maflcko:2408-test-less-curl

Conversation

@maflcko

@maflcko maflcko commented Aug 23, 2024

Copy link
Copy Markdown
Member

Seems odd having to translate 404 to "Binary tag was not found". Also, it seems odd to write a for-loop over a list with one item.

Fix both issues by just using a single call to curl --fail ....

Can be tested with: test/get_previous_releases.py -b v99.99.99

Before:

Releases directory: releases
Fetching: https://bitcoincore.org/bin/bitcoin-core-99.99.99/bitcoin-99.99.99-x86_64-linux-gnu.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  286k    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
Binary tag was not found

After:

Releases directory: releases
Fetching: https://bitcoincore.org/bin/bitcoin-core-99.99.99/bitcoin-99.99.99-x86_64-linux-gnu.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  286k    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (22) The requested URL returned error: 404

@DrahtBot

DrahtBot commented Aug 23, 2024 •

Copy link
Copy Markdown
Contributor

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.

Type Reviewers
ACK fanquake, brunoerg, tdb3

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot DrahtBot added the Tests label Aug 23, 2024

@fanquake fanquake left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK fa5aeab

@brunoerg brunoerg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK fa5aeab

@tdb3 tdb3 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tested ACK fa5aeab
Seems to work well and is an elegant simplification. Thank you.

Not that it seems to matter for callers of get_previous_releases.py, but just noting that previously download_binary() returned 1 on 404, while the new approach returns 22 (as documented in curl's man page, ...at least with curl 7.88.1 (x86_64-pc-linux-gnu)).

previous:

$ test/get_previous_releases.py -b v29.0
Releases directory: releases
Fetching: https://bitcoincore.org/bin/bitcoin-core-29.0/bitcoin-29.0-x86_64-linux-gnu.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  286k    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Binary tag was not found
$ echo $?
1

new approach:

$ test/get_previous_releases.py -b v29.0
Releases directory: releases
Fetching: https://bitcoincore.org/bin/bitcoin-core-29.0/bitcoin-29.0-x86_64-linux-gnu.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  286k    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
$ echo $?
22

Also tested that downloading a valid release (v23.0) was successful.

@fanquake
fanquake merged commit d54fbc8 into bitcoin:master Aug 24, 2024
@maflcko
maflcko deleted the 2408-test-less-curl branch August 25, 2024 10:12
@bitcoin bitcoin locked and limited conversation to collaborators Aug 25, 2025
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.

5 participants