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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

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

Merged
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged

Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates on upgrade#3584
TheBlueMatt merged 5 commits into
lightningdevkit:mainfrom
TheBlueMatt:2025-02-upgrade-tests

Conversation

@TheBlueMatt

Copy link
Copy Markdown
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.

@TheBlueMattTheBlueMatt added this to the 0.2 milestone Feb 2, 2025

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.

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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

We chatted a bit more offline. To me the question is whether most devs run cargo test as their usual workflow or run ci-tests.sh. Indeed, devs need to run ci-tests.sh to hit "everything" but most things get hit with cargo test normally. With upgrade/downgrade tests, I fear that they're going to be as likely to fail as most other tests, if not more, so making devs (especially new devs who tend to hit this often) wait for a CI cycle before they find the bug is gonna be pretty annoying.

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.

That's a fair point, and I did go ahead and create a new crate for this reason. For now I left it in the workspace until we resolve the above question.

@valentinewallace

Copy link
Copy Markdown
Contributor

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

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from a237be2 to 44e1a54CompareMarch 4, 2025 19:16
@TheBlueMatt

TheBlueMatt commented Mar 4, 2025

Copy link
Copy Markdown
CollaboratorAuthor

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

@codecov

codecovBot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.

Project coverage is 90.99%. Comparing base (df68774) to head (f9fb216).
Report is 68 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/util/test_channel_signer.rs76.47%11 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs50.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3584 +/- ##
==========================================
+ Coverage 89.22% 90.99% +1.77% 
==========================================
Files 155 157 +2 Lines 118973 134041 +15068 Branches 118973 134041 +15068 ==========================================
+ Hits 106154 121975 +15821 + Misses 10239 9675 -564 + Partials 2580 2391 -189 

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 44e1a54 to b099963CompareMarch 4, 2025 20:57
@wpaulino

Copy link
Copy Markdown
Contributor

CI is still sad

@wpaulino

Copy link
Copy Markdown
Contributor
error: package ID specification `lightning-test` did not match any packages
Did you mean `lightning-tests`?

@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from 8c96d90 to f9fb216CompareMarch 11, 2025 19:21
@wpaulino

Copy link
Copy Markdown
Contributor

cargo doc -p lightning-tests --document-private-items seems to cause issues, we don't really need docs there anyway

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
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch 2 times, most recently from 171401f to c3f8144CompareMay 16, 2025 14:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Ooookayyyyyy. We discussed offline and it seems many folks who work on LDK do use cargo test -p lightning so moved the tests into a non-workspace crate entirely. Note that clippy is failing but that'll be fixed by #3782. Also went ahead and rebased and squashed since its been so long since this was put up.

@TheBlueMatt
TheBlueMatt requested review from tnull and removed request for tnullMay 16, 2025 14:40
@TheBlueMatt
TheBlueMatt requested review from wpaulino and removed request for jkczyzMay 19, 2025 17:55
wpaulino
wpaulino previously approved these changes May 19, 2025

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

LGTM, two questions.

Comment threadlightning-tests/Cargo.toml Outdated
lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }
lightning-macros = { version = "0.2", path = "../lightning-macros" }
lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }

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.

Should these be using the +git version numbers, which also might help remembering to bump them post-release?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Actually we don't even need the version tag, removed them.

Comment threadci/ci-tests.sh
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.
Running `cargo test -p crate` for each crate in the workspace
results in re-building the `lightning` crate for each workspace
crate, which can be quite slow. This adds nontrivial time to our
total CI runs.
Here, instead, we just run `cargo test` and let it build the whole
workspace crate list in one go. This does result in combined
features which may leave some issues with `cargo test -p crate`
undetected, but there's not a ton of harm to that.
@TheBlueMatt
TheBlueMattforce-pushed the 2025-02-upgrade-tests branch from c3f8144 to 86c661aCompareMay 21, 2025 15:39
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Squash pushed a quick Cargo.toml simplification:

$ git diff-tree -U1 c3f8144222 86c661a5e6
diff --git a/lightning-tests/Cargo.toml b/lightning-tests/Cargo.toml
index 01ad635580..75c68e03f5 100644
--- a/lightning-tests/Cargo.toml+++ b/lightning-tests/Cargo.toml@@ -12,6 +12,6 @@ edition = "2021"
[dependencies]
-lightning-types = { version = "0.3.0", path = "../lightning-types", features = ["_test_utils"] }-lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false }-lightning-macros = { version = "0.2", path = "../lightning-macros" }-lightning = { version = "0.2", path = "../lightning", features = ["_test_utils"] }+lightning-types = { path = "../lightning-types", features = ["_test_utils"] }+lightning-invoice = { path = "../lightning-invoice", default-features = false }+lightning-macros = { path = "../lightning-macros" }+lightning = { path = "../lightning", features = ["_test_utils"] }
lightning_0_1 = { package = "lightning", version = "0.1.1", features = ["_test_utils"] }

@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

@tnull already said "LGTM" and the one remaining question was addressed, landing since i want to base more PRs on this.

@TheBlueMatt
TheBlueMatt merged commit 02b5564 into lightningdevkit:mainMay 21, 2025

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

Post-merge ACK

@TheBlueMattTheBlueMatt mentioned this pull request May 23, 2025
@TheBlueMatt

Copy link
Copy Markdown
CollaboratorAuthor

Partially backported in #3794

@TheBlueMattTheBlueMatt linked an issue Jul 7, 2025 that may be closed by this pull request
Sign up for freeto 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.

Cross-Version (De-)Serialization Tests

4 participants

@TheBlueMatt@valentinewallace@wpaulino@tnull