_ => panic!("Unexpected event"),
}
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
// Now set it to failed again...
let (_, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
// Claim the previous payment, which will result in a update_fulfill_htlc/CS from nodes[1]
// but nodes[0] won't respond since it is frozen.
- assert!(nodes[1].node.claim_funds(payment_preimage_1));
+ assert!(nodes[1].node.claim_funds(payment_preimage_1, 1_000_000));
check_added_monitors!(nodes[1], 1);
let events_2 = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events_2.len(), 1);
_ => panic!("Unexpected event"),
}
- if let Err(msgs::HandleError{err, action: Some(msgs::ErrorAction::IgnoreError) }) = nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), commitment_signed) {
+ if let Err(msgs::LightningError{err, action: msgs::ErrorAction::IgnoreError }) = nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), commitment_signed) {
assert_eq!(err, "Previous monitor update failure prevented generation of RAA");
} else { panic!(); }
}
_ => panic!("Unexpected event"),
}
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2, 1_000_000);
}
#[test]
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send_event.msgs[0]).unwrap();
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send_event.commitment_msg).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send_event.commitment_msg).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
*nodes[0].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &updates.commitment_signed).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &updates.commitment_signed).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[0], 1);
_ => panic!("Unexpected event"),
};
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage, 1_000_000);
}
#[test]
let bs_raa = commitment_signed_dance!(nodes[1], nodes[0], send_event.commitment_msg, false, true, false, true);
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &bs_raa).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &bs_raa).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
_ => panic!("Unexpected event"),
}
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
}
#[test]
let mut nodes = create_network(2, &[None, None]);
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
- send_payment(&nodes[0], &[&nodes[1]], 5000000);
+ send_payment(&nodes[0], &[&nodes[1]], 5000000, 5_000_000);
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
let (payment_preimage_1, our_payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
*nodes[0].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &send_event_2.msgs[0]).unwrap();
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_event_2.commitment_msg).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &send_event_2.commitment_msg).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[0], 1);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_raa).unwrap_err() {
assert_eq!(err, "Previous monitor update failure prevented responses to RAA");
} else { panic!(); }
check_added_monitors!(nodes[0], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_received!(nodes[1], our_payment_hash_1, 1000000);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1);
- claim_payment(&nodes[1], &[&nodes[0]], payment_preimage_2);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
+ claim_payment(&nodes[1], &[&nodes[0]], payment_preimage_2, 1_000_000);
}
fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
// Rebalance a bit so that we can send backwards from 2 to 1.
- send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
+ send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
// Route a first payment that we'll fail backwards
let (_, payment_hash_1) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
// Now fail monitor updating.
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_revoke_and_ack).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_revoke_and_ack(&nodes[2].node.get_our_node_id(), &bs_revoke_and_ack).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
send_event = SendEvent::from_event(nodes[2].node.get_and_clear_pending_msg_events().remove(0));
nodes[1].node.handle_update_add_htlc(&nodes[2].node.get_our_node_id(), &send_event.msgs[0]).unwrap();
- if let Err(msgs::HandleError{err, action: Some(msgs::ErrorAction::IgnoreError) }) = nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &send_event.commitment_msg) {
+ if let Err(msgs::LightningError{err, action: msgs::ErrorAction::IgnoreError }) = nodes[1].node.handle_commitment_signed(&nodes[2].node.get_our_node_id(), &send_event.commitment_msg) {
assert_eq!(err, "Previous monitor update failure prevented generation of RAA");
} else { panic!(); }
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
Event::PaymentReceived { payment_hash, .. } => assert_eq!(payment_hash, payment_hash_4.unwrap()),
_ => panic!("Unexpected event"),
};
- claim_payment(&nodes[2], &[&nodes[1], &nodes[0]], payment_preimage_4.unwrap());
+ claim_payment(&nodes[2], &[&nodes[1], &nodes[0]], payment_preimage_4.unwrap(), 1_000_000);
}
- claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage_2);
+ claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage_2, 1_000_000);
}
#[test]
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
- assert!(nodes[2].node.claim_funds(our_payment_preimage));
+ assert!(nodes[2].node.claim_funds(our_payment_preimage, 1_000_000));
check_added_monitors!(nodes[2], 1);
let mut updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
assert!(updates.update_add_htlcs.is_empty());
nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish).unwrap();
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
// then restore channel monitor updates.
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]).unwrap();
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa).unwrap_err() {
assert_eq!(err, "Previous monitor update failure prevented responses to RAA");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_received!(nodes[1], payment_hash_3, 1000000);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_3);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2, 1_000_000);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_3, 1_000_000);
}
#[test]
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);
- assert!(nodes[1].node.claim_funds(payment_preimage_1));
+ assert!(nodes[1].node.claim_funds(payment_preimage_1, 1_000_000));
check_added_monitors!(nodes[1], 1);
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id());
// update.
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reconnect).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reconnect).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
let as_updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_updates.update_add_htlcs[0]).unwrap();
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_updates.commitment_signed).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_updates.commitment_signed).unwrap_err() {
assert_eq!(err, "Previous monitor update failure prevented generation of RAA");
} else { panic!(); }
// Note that nodes[1] not updating monitor here is OK - it wont take action on the new HTLC
_ => panic!("Unexpected event"),
}
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2, 1_000_000);
}
#[test]
assert_eq!(events.len(), 1);
let payment_event = SendEvent::from_event(events.pop().unwrap());
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]).unwrap();
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_received!(nodes[1], payment_hash_1, 1000000);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
}
#[test]
// Deliver the final RAA for the first payment, which does not require a response. RAAs
// generally require a commitment_signed, so the fact that we're expecting an opposite response
// to the next message also tests resetting the delivery order.
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &as_raa).unwrap_err() {
assert_eq!(err, "Failed to update ChannelMonitor");
} else { panic!(); }
check_added_monitors!(nodes[1], 1);
// RAA/CS response, which should be generated when we call test_restore_channel_monitor (with
// the appropriate HTLC acceptance).
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]).unwrap();
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg).unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg).unwrap_err() {
assert_eq!(err, "Previous monitor update failure prevented generation of RAA");
} else { panic!(); }
expect_pending_htlcs_forwardable!(nodes[1]);
expect_payment_received!(nodes[1], payment_hash_2, 1000000);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2, 1_000_000);
}
#[test]
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
// Rebalance a bit so that we can send backwards from 3 to 2.
- send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
+ send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- assert!(nodes[1].node.claim_funds(payment_preimage_1));
+ assert!(nodes[1].node.claim_funds(payment_preimage_1, 1_000_000));
check_added_monitors!(nodes[1], 1);
let route = nodes[2].router.get_route(&nodes[0].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
// Rebalance a bit so that we can send backwards from 3 to 1.
- send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
+ send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
let (_, payment_hash_1) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
assert!(nodes[2].node.fail_htlc_backwards(&payment_hash_1));
nodes[0].node.process_pending_htlc_forwards();
expect_payment_received!(nodes[0], payment_hash_2, 1000000);
- claim_payment(&nodes[2], &[&nodes[1], &nodes[0]], payment_preimage_2);
+ claim_payment(&nodes[2], &[&nodes[1], &nodes[0]], payment_preimage_2, 1_000_000);
}
#[test]
let as_raa = commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false, true, false, true);
*nodes[1].chan_monitor.update_ret.lock().unwrap() = Err(ChannelMonitorUpdateErr::TemporaryFailure);
- assert!(nodes[1].node.claim_funds(payment_preimage_1));
+ assert!(nodes[1].node.claim_funds(payment_preimage_1, 1_000_000));
check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
_ => panic!("Unexpected event"),
}
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2);
+ claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2, 1_000_000);
}
// Note that restore_between_fails with !fail_on_generate is useless
}
let funding_signed_res = nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
if fail_on_signed || !restore_between_fails {
- if let msgs::HandleError { err, action: Some(msgs::ErrorAction::IgnoreError) } = funding_signed_res.unwrap_err() {
+ if let msgs::LightningError { err, action: msgs::ErrorAction::IgnoreError } = funding_signed_res.unwrap_err() {
if fail_on_generate && !restore_between_fails {
assert_eq!(err, "Previous monitor update failure prevented funding_signed from allowing funding broadcast");
check_added_monitors!(nodes[0], 0);
node.router.handle_channel_update(&bs_update).unwrap();
}
- send_payment(&nodes[0], &[&nodes[1]], 8000000);
+ send_payment(&nodes[0], &[&nodes[1]], 8000000, 8_000_000);
close_channel(&nodes[0], &nodes[1], &channel_id, funding_tx, true);
}