+ assert!(!substantially_old || !not_stale, "substantially_old and not_stale doesn't make sense");
+ if not_stale || !substantially_old {
+ // Previously, we'd only hit the data_loss_protect assertion if we had a state which
+ // revoked at least two revocations ago, not the latest revocation. Here, we use
+ // `not_stale` to test the boundary condition.
+ let pay_params = PaymentParameters::for_keysend(nodes[1].node.get_our_node_id(), 100, false);
+ let route_params = RouteParameters::from_payment_params_and_value(pay_params, 40000);
+ nodes[0].node.send_spontaneous_payment_with_retry(None, RecipientOnionFields::spontaneous_empty(), PaymentId([0; 32]), route_params, Retry::Attempts(0)).unwrap();
+ check_added_monitors(&nodes[0], 1);
+ let update_add_commit = SendEvent::from_node(&nodes[0]);
+
+ nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_commit.msgs[0]);
+ nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &update_add_commit.commitment_msg);
+ check_added_monitors(&nodes[1], 1);
+ let (raa, cs) = get_revoke_commit_msgs(&nodes[1], &nodes[0].node.get_our_node_id());
+
+ nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &raa);
+ check_added_monitors(&nodes[0], 1);
+ assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
+ if !not_stale {
+ nodes[0].node.handle_commitment_signed(&nodes[1].node.get_our_node_id(), &cs);
+ check_added_monitors(&nodes[0], 1);
+ // A now revokes their original state, at which point reconnect should panic
+ let raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
+ nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa);
+ check_added_monitors(&nodes[1], 1);
+ expect_pending_htlcs_forwardable_ignore!(nodes[1]);
+ }
+ } else {
+ send_payment(&nodes[0], &[&nodes[1]], 8000000);
+ send_payment(&nodes[0], &[&nodes[1]], 8000000);
+ }