|  | 
|  | 1 | +// This file is Copyright its original authors, visible in version control | 
|  | 2 | +// history. | 
|  | 3 | +// | 
|  | 4 | +// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE | 
|  | 5 | +// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | 
|  | 6 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. | 
|  | 7 | +// You may not use this file except in accordance with one or both of these | 
|  | 8 | +// licenses. | 
|  | 9 | + | 
|  | 10 | +//! Tests which test upgrading from previous versions of LDK or downgrading to previous versions of | 
|  | 11 | +//! LDK. | 
|  | 12 | +
 | 
|  | 13 | +use lightning_0_1::ln::functional_test_utils as lightning_0_1_utils; | 
|  | 14 | +use lightning_0_1::get_monitor as get_monitor_0_1; | 
|  | 15 | +use lightning_0_1::util::ser::Writeable; | 
|  | 16 | + | 
|  | 17 | +use crate::ln::functional_test_utils::*; | 
|  | 18 | +use crate::types::payment::PaymentPreimage; | 
|  | 19 | + | 
|  | 20 | +#[test] | 
|  | 21 | +fn simple_upgrade() { | 
|  | 22 | +	// Tests a simple case of upgrading from LDK 0.1 with a pending payment | 
|  | 23 | +	let (node_a, node_b, mon_a, mon_b, preimage); | 
|  | 24 | +	{ | 
|  | 25 | +		let chanmon_cfgs = lightning_0_1_utils::create_chanmon_cfgs(2); | 
|  | 26 | +		let node_cfgs = lightning_0_1_utils::create_node_cfgs(2, &chanmon_cfgs); | 
|  | 27 | +		let node_chanmgrs = lightning_0_1_utils::create_node_chanmgrs(2, &node_cfgs, &[None, None]); | 
|  | 28 | +		let nodes = lightning_0_1_utils::create_network(2, &node_cfgs, &node_chanmgrs); | 
|  | 29 | + | 
|  | 30 | +		let chan_id = lightning_0_1_utils::create_announced_chan_between_nodes(&nodes, 0, 1).2; | 
|  | 31 | + | 
|  | 32 | +		let payment_preimage = lightning_0_1_utils::route_payment(&nodes[0], &[&nodes[1]], 1_000_000); | 
|  | 33 | +		preimage = PaymentPreimage(payment_preimage.0.0); | 
|  | 34 | + | 
|  | 35 | +		node_a = nodes[0].node.encode(); | 
|  | 36 | +		node_b = nodes[1].node.encode(); | 
|  | 37 | +		mon_a = get_monitor_0_1!(nodes[0], chan_id).encode(); | 
|  | 38 | +		mon_b = get_monitor_0_1!(nodes[1], chan_id).encode(); | 
|  | 39 | +	} | 
|  | 40 | + | 
|  | 41 | +	// Create a dummy node to reload over with the 0.1 state | 
|  | 42 | + | 
|  | 43 | +	let mut chanmon_cfgs = create_chanmon_cfgs(2); | 
|  | 44 | + | 
|  | 45 | +	// Our TestChannelSigner will fail as we're jumping ahead, so disable its state-based checks | 
|  | 46 | +	chanmon_cfgs[0].keys_manager.disable_all_state_policy_checks = true; | 
|  | 47 | +	chanmon_cfgs[1].keys_manager.disable_all_state_policy_checks = true; | 
|  | 48 | + | 
|  | 49 | +	let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); | 
|  | 50 | +	let (persister_a, persister_b, chain_monitor_a, chain_monitor_b); | 
|  | 51 | +	let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); | 
|  | 52 | +	let (node_deser_a, node_deser_b); | 
|  | 53 | +	let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); | 
|  | 54 | + | 
|  | 55 | +	reload_node!(nodes[0], test_default_channel_config(), &node_a, &[&mon_a], persister_a, chain_monitor_a, node_deser_a); | 
|  | 56 | +	reload_node!(nodes[1], test_default_channel_config(), &node_b, &[&mon_b], persister_b, chain_monitor_b, node_deser_b); | 
|  | 57 | + | 
|  | 58 | +	reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1])); | 
|  | 59 | + | 
|  | 60 | +	claim_payment(&nodes[0], &[&nodes[1]], preimage); | 
|  | 61 | +} | 
0 commit comments