X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchanmon_update_fail_tests.rs;h=0d2b3b6a9f941c117c80465b7ff886f329a349ad;hb=17ec697f8f09d608f6a3d2703ed4f4409773b4bf;hp=af4b024a8e977547edad1ff83cce929472692e12;hpb=a12d37e0633d94f1651cd24b656024b84f68e3cb;p=rust-lightning diff --git a/lightning/src/ln/chanmon_update_fail_tests.rs b/lightning/src/ln/chanmon_update_fail_tests.rs index af4b024a..0d2b3b6a 100644 --- a/lightning/src/ln/chanmon_update_fail_tests.rs +++ b/lightning/src/ln/chanmon_update_fail_tests.rs @@ -103,7 +103,7 @@ fn test_monitor_and_persister_update_fail() { // Because we will connect a block at height 200 below, we need the TestBroadcaster to know // that we are at height 200 so that it doesn't think we're violating the time lock // requirements of transactions broadcasted at that point. - blocks: Arc::new(Mutex::new(vec![(genesis_block(Network::Testnet).header, 200); 200])), + blocks: Arc::new(Mutex::new(vec![(genesis_block(Network::Testnet), 200); 200])), }; let chain_mon = { let monitor = nodes[0].chain_monitor.chain_monitor.get_monitor(outpoint).unwrap(); @@ -191,9 +191,9 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) { let events_3 = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events_3.len(), 1); match events_3[0] { - Event::PaymentReceived { ref payment_hash, ref purpose, amt } => { + Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat } => { assert_eq!(payment_hash_1, *payment_hash); - assert_eq!(amt, 1000000); + assert_eq!(amount_msat, 1_000_000); match &purpose { PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -226,7 +226,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) { } // ...and make sure we can force-close a frozen channel - nodes[0].node.force_close_channel(&channel_id, &nodes[1].node.get_our_node_id()).unwrap(); + nodes[0].node.force_close_broadcasting_latest_txn(&channel_id, &nodes[1].node.get_our_node_id()).unwrap(); check_added_monitors!(nodes[0], 1); check_closed_broadcast!(nodes[0], true); @@ -559,9 +559,9 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) { let events_5 = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events_5.len(), 1); match events_5[0] { - Event::PaymentReceived { ref payment_hash, ref purpose, amt } => { + Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat } => { assert_eq!(payment_hash_2, *payment_hash); - assert_eq!(amt, 1000000); + assert_eq!(amount_msat, 1_000_000); match &purpose { PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -676,9 +676,9 @@ fn test_monitor_update_fail_cs() { let events = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::PaymentReceived { payment_hash, ref purpose, amt } => { + Event::PaymentReceived { payment_hash, ref purpose, amount_msat } => { assert_eq!(payment_hash, our_payment_hash); - assert_eq!(amt, 1000000); + assert_eq!(amount_msat, 1_000_000); match &purpose { PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -1650,9 +1650,9 @@ fn test_monitor_update_fail_claim() { let events = nodes[0].node.get_and_clear_pending_events(); assert_eq!(events.len(), 2); match events[0] { - Event::PaymentReceived { ref payment_hash, ref purpose, amt } => { + Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat } => { assert_eq!(payment_hash_2, *payment_hash); - assert_eq!(1_000_000, amt); + assert_eq!(1_000_000, amount_msat); match &purpose { PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -1664,9 +1664,9 @@ fn test_monitor_update_fail_claim() { _ => panic!("Unexpected event"), } match events[1] { - Event::PaymentReceived { ref payment_hash, ref purpose, amt } => { + Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat } => { assert_eq!(payment_hash_3, *payment_hash); - assert_eq!(1_000_000, amt); + assert_eq!(1_000_000, amount_msat); match &purpose { PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -1848,7 +1848,7 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf: if confirm_a_first { confirm_transaction(&nodes[0], &funding_tx); - nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingLocked, nodes[1].node.get_our_node_id())); + nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id())); assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); assert!(nodes[1].node.get_and_clear_pending_events().is_empty()); } else { @@ -1857,7 +1857,7 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf: assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); } - // Make sure nodes[1] isn't stupid enough to re-send the FundingLocked on reconnect + // Make sure nodes[1] isn't stupid enough to re-send the ChannelReady on reconnect nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false); nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false); reconnect_nodes(&nodes[0], &nodes[1], (false, confirm_a_first), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false)); @@ -1871,7 +1871,7 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf: } if !confirm_a_first && !restore_b_before_lock { confirm_transaction(&nodes[0], &funding_tx); - nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingLocked, nodes[1].node.get_our_node_id())); + nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id())); assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); assert!(nodes[1].node.get_and_clear_pending_events().is_empty()); } @@ -1883,13 +1883,13 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf: let (channel_id, (announcement, as_update, bs_update)) = if !confirm_a_first { if !restore_b_before_lock { - let (funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]); - (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &funding_locked)) + let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]); + (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &channel_ready)) } else { - nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id())); + nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id())); confirm_transaction(&nodes[0], &funding_tx); - let (funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]); - (channel_id, create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &funding_locked)) + let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]); + (channel_id, create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready)) } } else { if restore_b_before_conf { @@ -1897,13 +1897,13 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf: assert!(nodes[1].node.get_and_clear_pending_events().is_empty()); confirm_transaction(&nodes[1], &funding_tx); } - let (funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]); - (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &funding_locked)) + let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]); + (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &channel_ready)) }; for node in nodes.iter() { - assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap()); - node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap(); - node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap(); + assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap()); + node.gossip_sync.handle_channel_update(&as_update).unwrap(); + node.gossip_sync.handle_channel_update(&bs_update).unwrap(); } send_payment(&nodes[0], &[&nodes[1]], 8000000); @@ -2541,7 +2541,7 @@ fn test_temporary_error_during_shutdown() { // Test that temporary failures when updating the monitor's shutdown script delay cooperative // close. let mut config = test_default_channel_config(); - config.channel_options.commit_upfront_shutdown_pubkey = false; + config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let chanmon_cfgs = create_chanmon_cfgs(2); let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); @@ -2596,7 +2596,7 @@ fn test_permanent_error_during_sending_shutdown() { // Test that permanent failures when updating the monitor's shutdown script result in a force // close when initiating a cooperative close. let mut config = test_default_channel_config(); - config.channel_options.commit_upfront_shutdown_pubkey = false; + config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let chanmon_cfgs = create_chanmon_cfgs(2); let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); @@ -2617,7 +2617,7 @@ fn test_permanent_error_during_handling_shutdown() { // Test that permanent failures when updating the monitor's shutdown script result in a force // close when handling a cooperative close. let mut config = test_default_channel_config(); - config.channel_options.commit_upfront_shutdown_pubkey = false; + config.channel_handshake_config.commit_upfront_shutdown_pubkey = false; let chanmon_cfgs = create_chanmon_cfgs(2); let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);