Skip to content

Commit 2201c25

Browse files
committed
Add backwards compatibility test for non-VSS
We previously added a test asserting backwards compatibility for nodes reinitializing from a VSS backend. However, given VSS tests are only continously run in CI we here add the same test using the default SQLite backend, ensuring backwards compatibility breakage is also checked when running tests locally.
1 parent eb83234 commit 2201c25

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "
8888
proptest = "1.0.0"
8989
regex = "1.5.6"
9090
criterion = { version = "0.7.0", features = ["async_tokio"] }
91+
ldk-node-062 = { package = "ldk-node", version = "=0.6.2" }
9192

9293
[target.'cfg(not(no_download))'.dev-dependencies]
9394
electrsd = { version = "0.36.1", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }
@@ -103,9 +104,6 @@ clightningrpc = { version = "0.3.0-beta.8", default-features = false }
103104
lnd_grpc_rust = { version = "2.10.0", default-features = false }
104105
tokio = { version = "1.37", features = ["fs"] }
105106

106-
[target.'cfg(vss_test)'.dev-dependencies]
107-
ldk-node-062 = { package = "ldk-node", version = "=0.6.2" }
108-
109107
[build-dependencies]
110108
uniffi = { version = "0.28.3", features = ["build"], optional = true }
111109

tests/integration_tests_rust.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use common::{
2727
TestSyncStore,
2828
};
2929
use ldk_node::config::{AsyncPaymentsRole, EsploraSyncConfig};
30+
use ldk_node::entropy::NodeEntropy;
3031
use ldk_node::liquidity::LSPS2ServiceConfig;
3132
use ldk_node::payment::{
3233
ConfirmationStatus, PaymentDetails, PaymentDirection, PaymentKind, PaymentStatus,
@@ -39,6 +40,7 @@ use lightning::routing::router::RouteParametersConfig;
3940
use lightning_invoice::{Bolt11InvoiceDescription, Description};
4041
use lightning_types::payment::{PaymentHash, PaymentPreimage};
4142
use log::LevelFilter;
43+
use rand::{rng, Rng};
4244

4345
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
4446
async fn channel_full_cycle() {
@@ -2436,3 +2438,65 @@ async fn payment_persistence_after_restart() {
24362438

24372439
restarted_node_a.stop().unwrap();
24382440
}
2441+
2442+
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
2443+
async fn persistence_backwards_compatibility() {
2444+
let (bitcoind, electrsd) = common::setup_bitcoind_and_electrsd();
2445+
let esplora_url = format!("http://{}", electrsd.esplora_url.as_ref().unwrap());
2446+
2447+
let storage_path = common::random_storage_path().to_str().unwrap().to_owned();
2448+
let seed_bytes = [42u8; 64];
2449+
let node_entropy = NodeEntropy::from_seed_bytes(seed_bytes);
2450+
2451+
// Setup a v0.6.2 `Node` persisted with the v0 scheme.
2452+
let (old_balance, old_node_id) = {
2453+
let mut builder_old = ldk_node_062::Builder::new();
2454+
builder_old.set_network(bitcoin::Network::Regtest);
2455+
builder_old.set_storage_dir_path(storage_path.clone());
2456+
builder_old.set_entropy_seed_bytes(seed_bytes);
2457+
builder_old.set_chain_source_esplora(esplora_url.clone(), None);
2458+
let node_old = builder_old.build().unwrap();
2459+
2460+
node_old.start().unwrap();
2461+
let addr_old = node_old.onchain_payment().new_address().unwrap();
2462+
common::premine_and_distribute_funds(
2463+
&bitcoind.client,
2464+
&electrsd.client,
2465+
vec![addr_old],
2466+
bitcoin::Amount::from_sat(100_000),
2467+
)
2468+
.await;
2469+
node_old.sync_wallets().unwrap();
2470+
2471+
let balance = node_old.list_balances().spendable_onchain_balance_sats;
2472+
assert!(balance > 0);
2473+
let node_id = node_old.node_id();
2474+
2475+
// Workaround necessary as v0.6.2's VSS runtime wasn't dropsafe in a tokio context.
2476+
tokio::task::block_in_place(move || {
2477+
node_old.stop().unwrap();
2478+
drop(node_old);
2479+
});
2480+
2481+
(balance, node_id)
2482+
};
2483+
2484+
// Now ensure we can still reinit from the same backend.
2485+
let mut builder_new = Builder::new();
2486+
builder_new.set_network(bitcoin::Network::Regtest);
2487+
builder_new.set_storage_dir_path(storage_path);
2488+
builder_new.set_chain_source_esplora(esplora_url, None);
2489+
2490+
let node_new = builder_new.build(node_entropy).unwrap();
2491+
2492+
node_new.start().unwrap();
2493+
node_new.sync_wallets().unwrap();
2494+
2495+
let new_balance = node_new.list_balances().spendable_onchain_balance_sats;
2496+
let new_node_id = node_new.node_id();
2497+
2498+
assert_eq!(old_node_id, new_node_id);
2499+
assert_eq!(old_balance, new_balance);
2500+
2501+
node_new.stop().unwrap();
2502+
}

0 commit comments

Comments
 (0)