Skip to content
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

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade #3584

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TheBlueMatt
Copy link
Collaborator

One major hole in our test coverage historically has been tests
covering upgrades or downgrades across LDK versions. Luckily, these
aren't particularly hard to write as cargo lets us depend on
previous versions of the lightning crate directly, which we can
use in tests.

Here we add a simple initial test of upgrading from LDK 0.1 while
there's a pending payment to be claimed.

@TheBlueMatt TheBlueMatt added this to the 0.2 milestone Feb 2, 2025
@TheBlueMatt TheBlueMatt force-pushed the 2025-02-upgrade-tests branch from 708a5cc to a237be2 Compare February 2, 2025 19:42
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to have this live in a dedicated tests crate or in the integration tests (tests) folder? This would also allow us to keep our testing script untouched, IIUC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmmm, yea, we definitely could. I'm kinda on the fence. On the one hand, you're right, we'd be able to do cargo -p lightning which is really nice, on the other hand we wouldn't run the upgrade tests with cargo test, which kinda sucks (and means yet more cases of things passing trivially but failing in CI). Do you have a strong opinion here?

Copy link
Contributor

Choose a reason for hiding this comment

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

we wouldn't run the upgrade tests with cargo test, which kinda sucks (and means yet more cases of things passing trivially but failing in CI).

Huh, but integration tests are run via cargo test, just after normal unit tests are run?

Do you have a strong opinion here?

Yeah, kinda tbh, I'd prefer to not interweave yet another layer of complexity into CI & dependency scripts. I agree we should see that tests are always run in CI and easy to run locally, but would prefer to have them live separately from the code and unit tests.

Note we could either have integration tests live as lightning/tests, or, especially if we think that we'd want to add more cross-crate tests there over time, could add them as a new member crate to the workspace at /lightning-tests. While the former is a bit more focused on lightning, the latter would open the door for moving some of the tests in lightning-background-processor there, which currently acts as the defacto place for integration tests as it's the only place in the dependency tree that allows for accessing all the necessary objects.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Huh, but integration tests are run via cargo test, just after normal unit tests are run?
Note we could either have integration tests live as lightning/tests

I don't see a way to add a separate dependency to the normal rust integration test files. We'd have to do it as a proper crate with a proper Cargo.toml, which I assume wouldn't get run like integration tests would.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, that's true. Then IMO it might be preferable to just add a lightning-tests crate to the workspace? Yes, it wouldn't get run by cargo test, but by the ci-tests.sh, which we already need to run anyways to cover all feature variants, etc?

@valentinewallace
Copy link
Contributor

LGTM after @tnull's feedback is resolved (and it looks like this need rebase). Nice to have this testing infra!

In e8854f9 we changed the type of
`ChannelManager::in_flight_monitor_updates`, writing a legacy
version and reading the new version as a new TLV field. Sadly, we
spuriously marked the new TLV as `required`, breaking upgrade from
0.1.

Here we fix the oversight by simply marking it `option`al.
The code was a bit too long to begin with, and rustfmt made a total
mess of it, so instead we should be building with more intermediate
variables.
The signer we use in tests tracks the state of the channel and
refuses to sign when the channel attempts an invalid state
transition. In the next commit, however, we'll add an upgrade test
which will fail these checks as the the state won't get copied from
previous versions of LDK to this version.

Thus, here, we add the ability to disable all state-based checks
in the signer.
@TheBlueMatt TheBlueMatt force-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54 Compare March 4, 2025 19:16
@TheBlueMatt
Copy link
Collaborator Author

TheBlueMatt commented Mar 4, 2025

Rebased. I pinged @tnull offline but dunno when/if he'll respond, there's also no rush.

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 84.37500% with 15 lines in your changes missing coverage. Please review.

Project coverage is 89.17%. Comparing base (df68774) to head (b099963).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/util/test_channel_signer.rs 68.75% 13 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3584      +/-   ##
==========================================
- Coverage   89.22%   89.17%   -0.06%     
==========================================
  Files         155      156       +1     
  Lines      118973   119029      +56     
  Branches   118973   119029      +56     
==========================================
- Hits       106154   106139      -15     
- Misses      10239    10291      +52     
- Partials     2580     2599      +19     

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

One major hole in our test coverage historically has been tests
covering upgrades or downgrades across LDK versions. Luckily, these
aren't particularly hard to write as cargo lets us depend on
previous versions of the `lightning` crate directly, which we can
use in tests.

Here we add a simple initial test of upgrading from LDK 0.1 while
there's a pending payment to be claimed.
@TheBlueMatt TheBlueMatt force-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963 Compare March 4, 2025 20:57
@wpaulino
Copy link
Contributor

wpaulino commented Mar 5, 2025

CI is still sad

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