|
| 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 crate::ln::functional_test_utils::*; |
| 14 | +use crate::ln::msgs::ChannelMessageHandler; |
| 15 | +use crate::types::payment::PaymentPreimage; |
| 16 | +use crate::util::ser::Writeable; |
| 17 | + |
| 18 | +#[test] |
| 19 | +fn simple_upgrade() { |
| 20 | + let chanmon_cfgs = create_chanmon_cfgs(2); |
| 21 | + let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); |
| 22 | + |
| 23 | + let (persister, chain_monitor); |
| 24 | + let nodes_0_deserialized; |
| 25 | + |
| 26 | + let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); |
| 27 | + let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); |
| 28 | + |
| 29 | + let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1).2; |
| 30 | + |
| 31 | + let payment_preimage = route_payment(&nodes[0], &[&nodes[1]], 1_000_000); |
| 32 | + let preimage = PaymentPreimage(payment_preimage.0.0); |
| 33 | + |
| 34 | + nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id()); |
| 35 | + nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id()); |
| 36 | + |
| 37 | + let node_a = nodes[0].node.encode(); |
| 38 | + let mon_a = get_monitor!(nodes[0], chan_id).encode(); |
| 39 | + |
| 40 | + reload_node!(nodes[0], test_default_channel_config(), &node_a, &[&mon_a], persister, chain_monitor, nodes_0_deserialized); |
| 41 | + |
| 42 | + reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1])); |
| 43 | + |
| 44 | + claim_payment(&nodes[0], &[&nodes[1]], preimage); |
| 45 | +} |
0 commit comments