Merge pull request #1062 from galderz/t_payment_hash_999
[rust-lightning] / lightning / src / ln / chanmon_update_fail_tests.rs
index 6901cc2f6394de9a5270895c713f659cd81afa8f..30088f2eba6815256990d634afa9e7ec1f2c5d53 100644 (file)
@@ -28,7 +28,7 @@ use ln::msgs::{ChannelMessageHandler, ErrorAction, RoutingMessageHandler};
 use routing::router::get_route;
 use util::config::UserConfig;
 use util::enforcing_trait_impls::EnforcingSigner;
-use util::events::{Event, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose};
+use util::events::{Event, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose, ClosureReason};
 use util::errors::APIError;
 use util::ser::{ReadableArgs, Writeable};
 use util::test_utils::TestBroadcaster;
@@ -78,9 +78,10 @@ fn do_test_simple_monitor_permanent_update_fail(persister_fail: bool) {
        };
 
        // TODO: Once we hit the chain with the failure transaction we should check that we get a
-       // PaymentFailed event
+       // PaymentPathFailed event
 
        assert_eq!(nodes[0].node.list_channels().len(), 0);
+       check_closed_event!(nodes[0], 1, ClosureReason::ProcessingError { err: "ChannelMonitor storage failure".to_string() });
 }
 
 #[test]
@@ -266,9 +267,10 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
        check_closed_broadcast!(nodes[0], true);
 
        // TODO: Once we hit the chain with the failure transaction we should check that we get a
-       // PaymentFailed event
+       // PaymentPathFailed event
 
        assert_eq!(nodes[0].node.list_channels().len(), 0);
+       check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed);
 }
 
 #[test]
@@ -1820,7 +1822,7 @@ fn test_monitor_update_on_pending_forwards() {
 
        let events = nodes[0].node.get_and_clear_pending_events();
        assert_eq!(events.len(), 2);
-       if let Event::PaymentFailed { payment_hash, rejected_by_dest, .. } = events[0] {
+       if let Event::PaymentPathFailed { payment_hash, rejected_by_dest, .. } = events[0] {
                assert_eq!(payment_hash, payment_hash_1);
                assert!(rejected_by_dest);
        } else { panic!("Unexpected event!"); }
@@ -1989,6 +1991,8 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
 
        send_payment(&nodes[0], &[&nodes[1]], 8000000);
        close_channel(&nodes[0], &nodes[1], &channel_id, funding_tx, true);
+       check_closed_event!(nodes[0], 1, ClosureReason::CooperativeClosure);
+       check_closed_event!(nodes[1], 1, ClosureReason::CooperativeClosure);
 }
 
 #[test]
@@ -2614,6 +2618,8 @@ fn test_temporary_error_during_shutdown() {
        assert_eq!(txn_a, txn_b);
        assert_eq!(txn_a.len(), 1);
        check_spends!(txn_a[0], funding_tx);
+       check_closed_event!(nodes[1], 1, ClosureReason::CooperativeClosure);
+       check_closed_event!(nodes[0], 1, ClosureReason::CooperativeClosure);
 }
 
 #[test]
@@ -2634,6 +2640,7 @@ fn test_permanent_error_during_sending_shutdown() {
        assert!(nodes[0].node.close_channel(&channel_id).is_ok());
        check_closed_broadcast!(nodes[0], true);
        check_added_monitors!(nodes[0], 2);
+       check_closed_event!(nodes[0], 1, ClosureReason::ProcessingError { err: "ChannelMonitor storage failure".to_string() });
 }
 
 #[test]
@@ -2656,6 +2663,7 @@ fn test_permanent_error_during_handling_shutdown() {
        nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &InitFeatures::known(), &shutdown);
        check_closed_broadcast!(nodes[1], true);
        check_added_monitors!(nodes[1], 2);
+       check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "ChannelMonitor storage failure".to_string() });
 }
 
 #[test]