-
Notifications
You must be signed in to change notification settings - Fork 406
Add a simple test of upgrading from LDK 0.1 and correct in_flight_monitor_updates
on upgrade
#3584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TheBlueMatt
merged 5 commits into
lightningdevkit:main
from
TheBlueMatt:2025-02-upgrade-tests
May 21, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
683e849
Correct `ChannelManager` `in_flight_monitor_updates` serialization
TheBlueMatt 5f247a6
Clean up `full_stack_target` `InMemorySigner` builder
TheBlueMatt 3b08fea
Optionally disable all state-based policy checks in test signer
TheBlueMatt 1e9d0c2
Add a simple test of upgrading from LDK 0.1
TheBlueMatt 86c661a
Test the whole workspace at once in `ci-tests.sh`
TheBlueMatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "lightning-tests" | ||
version = "0.0.1" | ||
authors = ["Matt Corallo"] | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/lightningdevkit/rust-lightning/" | ||
description = "Tests for LDK crates" | ||
edition = "2021" | ||
|
||
[features] | ||
|
||
[dependencies] | ||
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"] } | ||
|
||
bitcoin = { version = "0.32.2", default-features = false } | ||
|
||
[dev-dependencies] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg_attr(test, macro_use)] | ||
extern crate lightning; | ||
|
||
#[cfg(all(test, not(taproot)))] | ||
pub mod upgrade_downgrade_tests; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// This file is Copyright its original authors, visible in version control | ||
// history. | ||
// | ||
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE | ||
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. | ||
// You may not use this file except in accordance with one or both of these | ||
// licenses. | ||
|
||
//! Tests which test upgrading from previous versions of LDK or downgrading to previous versions of | ||
//! LDK. | ||
|
||
use lightning_0_1::get_monitor as get_monitor_0_1; | ||
use lightning_0_1::ln::functional_test_utils as lightning_0_1_utils; | ||
use lightning_0_1::util::ser::Writeable; | ||
|
||
use lightning::ln::functional_test_utils::*; | ||
|
||
use lightning_types::payment::PaymentPreimage; | ||
|
||
#[test] | ||
fn simple_upgrade() { | ||
// Tests a simple case of upgrading from LDK 0.1 with a pending payment | ||
let (node_a_ser, node_b_ser, mon_a_ser, mon_b_ser, preimage); | ||
{ | ||
let chanmon_cfgs = lightning_0_1_utils::create_chanmon_cfgs(2); | ||
let node_cfgs = lightning_0_1_utils::create_node_cfgs(2, &chanmon_cfgs); | ||
let node_chanmgrs = lightning_0_1_utils::create_node_chanmgrs(2, &node_cfgs, &[None, None]); | ||
let nodes = lightning_0_1_utils::create_network(2, &node_cfgs, &node_chanmgrs); | ||
|
||
let chan_id = lightning_0_1_utils::create_announced_chan_between_nodes(&nodes, 0, 1).2; | ||
|
||
let payment_preimage = | ||
lightning_0_1_utils::route_payment(&nodes[0], &[&nodes[1]], 1_000_000); | ||
preimage = PaymentPreimage(payment_preimage.0 .0); | ||
|
||
node_a_ser = nodes[0].node.encode(); | ||
node_b_ser = nodes[1].node.encode(); | ||
mon_a_ser = get_monitor_0_1!(nodes[0], chan_id).encode(); | ||
mon_b_ser = get_monitor_0_1!(nodes[1], chan_id).encode(); | ||
} | ||
|
||
// Create a dummy node to reload over with the 0.1 state | ||
|
||
let mut chanmon_cfgs = create_chanmon_cfgs(2); | ||
|
||
// Our TestChannelSigner will fail as we're jumping ahead, so disable its state-based checks | ||
chanmon_cfgs[0].keys_manager.disable_all_state_policy_checks = true; | ||
chanmon_cfgs[1].keys_manager.disable_all_state_policy_checks = true; | ||
|
||
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); | ||
let (persister_a, persister_b, chain_mon_a, chain_mon_b); | ||
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); | ||
let (node_a, node_b); | ||
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); | ||
|
||
let config = test_default_channel_config(); | ||
let a_mons = &[&mon_a_ser[..]]; | ||
reload_node!(nodes[0], config.clone(), &node_a_ser, a_mons, persister_a, chain_mon_a, node_a); | ||
reload_node!(nodes[1], config, &node_b_ser, &[&mon_b_ser], persister_b, chain_mon_b, node_b); | ||
|
||
reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1])); | ||
|
||
claim_payment(&nodes[0], &[&nodes[1]], preimage); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.