Skip to content

Replace lightning-block-sync test that depended on foo.com #2655

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

Merged
merged 1 commit into from
Oct 14, 2023

Conversation

TheBlueMatt
Copy link
Collaborator

Our tests should generally not rely on internet access, and should not rely on the behavior of any given remote server. However, one of the endpoint_tests in lightning-block-sync::http relied on foo.com resolving to a single socket address, which both might change in the future and makes our tests fail without internet.

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (eea19de) 89.00% compared to head (631f989) 89.27%.
Report is 10 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2655      +/-   ##
==========================================
+ Coverage   89.00%   89.27%   +0.27%     
==========================================
  Files         112      112              
  Lines       87157    88472    +1315     
  Branches    87157    88472    +1315     
==========================================
+ Hits        77574    78986    +1412     
+ Misses       7339     7301      -38     
+ Partials     2244     2185      -59     
Files Coverage Δ
lightning-block-sync/src/http.rs 88.74% <100.00%> (+0.19%) ⬆️

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

wpaulino
wpaulino previously approved these changes Oct 10, 2023
@wpaulino
Copy link
Contributor

Looks like https://bitcoincore.org is down?

@TheBlueMatt TheBlueMatt added this to the 0.0.118 milestone Oct 12, 2023
jkczyz
jkczyz previously approved these changes Oct 12, 2023
Comment on lines 524 to 525
assert!(http_addr.is_some(), "Expected socket address");
while let Some(addr) = http_addr {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could use peekable and iterate with a for loop.

Copy link
Collaborator Author

@TheBlueMatt TheBlueMatt Oct 13, 2023

Choose a reason for hiding this comment

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

Sure, dont even need peekable.

@TheBlueMatt TheBlueMatt dismissed stale reviews from jkczyz and wpaulino via 0753f20 October 13, 2023 02:50
@TheBlueMatt TheBlueMatt force-pushed the 2023-10-no-test-net branch 2 times, most recently from 0753f20 to 039ffa0 Compare October 13, 2023 02:51
Our tests should generally not rely on internet access, and should
not rely on the behavior of any given remote server. However, one
of the `endpoint_tests` in `lightning-block-sync::http` relied on
`foo.com` resolving to a single socket address, which both might
change in the future and makes our tests fail without internet.
}
assert!(std_addrs.next().is_none());
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we are assuming std_addrs contains at least one item? Probably fine but just want to call that out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, you need peekable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No? We only check that the two iterators are exactly equal, not that either contain anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, the old code made sure there was at least one with panic!("Expected socket address"). Without that, you may skip the check entirely if the size is zero, meaning the test isn't checking anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, yea, I don't think we need to check that. Like, in theory someone could have a horrendously misconfigured system where localhost doesn't resolve to anything. We shouldn't fail tests if that happens, though honestly I'm surprised that system is running and not randomly crashing in other places :)

@TheBlueMatt TheBlueMatt merged commit 2c51080 into lightningdevkit:main Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants